Jump to content

All Activity

This stream auto-updates     

  1. Today
  2. Yesterday
  3. Errors in editBox

    Thank you for reporting these. I need to find a way to reproduce the Object Inspector bug. When I test the Android.css -theme, I don't seem to have any problems entering text in editboxes. Do you have a test project that you could attach?
  4. webhooks

    It took me a while to get my head around the concept of webhooks. These have been around for 10 years or more but there is almost no to-the-point info or 'webhook-for-dummies' article on the web available. Webhooks are basically a notification system between disparate systems or servers, where the notifications are based on Http (XmlHttpRequests), so no messaging protocols or middleware software necessary. Like this : In this example there is a service which exposes changes in stock-prices. This service also has an api which allows applications to subscribe to this service (1). Subscription involves providing the url of the application-server. When a stock-price change event occurs, the service POST's a HttpRequest to the url of the server with a payload of the new price (2a) The server responds with a simple OK (2b) and initiates an action towards the client. This action can be maybe sending an email, or just sending a socket-message to the client (3) which allows the client to update its db or user-interface Setting this up in SMS takes a bit of effort as the servers need to have publicly accessible urls. Meaning nodejs servers have to be hosted somewhere (Heroku, Google Cloud). Doable I think.
  5. Last week
  6. NodeJS and HTTPS

    I see - fascinating! And thank you for a detailed and well thought out answer. I have an interest in such things because I myself have written a Pascal like compiler - from scratch. Well, it will eventually be a compiler when it is capable of actually generating object code. At present it only reads in a program and creates a tree out of objects. The constructor of each object reads in the program and creates sub objects that mirror the recursive structure of the program and resolving procedure, function calls and variable references along the way. It uses the shunting yard algorithm for constructing expressions. The tree is executable, and at present I'm using it as a simplified scripting language as a machinery control front end. I say simplified in that it is even more "wordy" than actual Pascal - i.e. many operators that are usually single character symbols can optionally be replaced with words. So a program can almost read like plain English for the benefit of the typical non programmer machine operators that use it... I also built in a feature where it can store its stack in a disc backed file so that it can resume execution after a power or computer failure etc. - that's useful in India where there are plenty of unpredictable power failures. The tree also stores pointers back to the corresponding source which allows the execution to be viewed in realtime etc. At present it only has 4 data types (Boolean, Integer, Real and String), and arrays - no type definitions or records yet. Variables can have read and write functions and procedures associated with them - so reading and writing to variables can have side effects - similar to properties. My eventual plan for that (mainly out of fascination with this sort of thing) is to extend it to output arbitrary assembler or machine code by using itself as a backend generator - i.e. the definition of the target CPU or assembler would itself be written in the language - allowing easy extension to new CPUs and differing architectures etc. I mainly view it as an interesting hobby - certainly nothing that hasn't been done before!
  7. Earlier
  8. Rest Api

    Hi. I'm trying TRestApi and I have a problem with external browsers I have tried using TRESTApi.Post, the connection is established and works Ok using the internal browser: the server receives a POST and send me data. But if I use it from firefox or chorme, the server receives an OPTIONS (no GET, no POST) and gets into an infinite loop until I close the page. If this did not happen I could forget about the sockets, I think. With Rest the code i use is: try FRestAPI := REST[IP, URL].OnError(gestionError); FRestAPI.Call .Header('Content-Type', 'application/json') .Header('Authorization',Token) .NoRandomize .OnDone( lambda(http) parsea(http.ResponseText); end ) .Post(resultado); finally FRestApi.Free; end; Usin external navegator, the server receive this. No return data and enter on an infinite loop. OPTIONS /api/myurl HTTP/1.1 Host: 192.168.1.170:8085 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3 Accept-Encoding: gzip, deflate Access-Control-Request-Method: POST Access-Control-Request-Headers: authorization,content-type Origin: http://192.168.1.101:8090 Connection: keep-alive usin internal navigator, the server receive this POST /api/PedidosLogistic HTTP/1.1 Host: 192.168.1.170:8085 Connection: keep-alive Content-Length: 45 Accept: */* Authorization: ;A2 Content-Type: application/json Origin: http://192.168.1.101:8090 User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36 Referer: http://192.168.1.101:8090/index.html Accept-Encoding: gzip, deflate Accept-Language: en-US,en;q=0.8
  9. POST by Sockets

    Sorry. I have connected to the url that you indicate to me (wss: //echo.websocket.org) and it has not given me any error, and show the message "Socket Connected!" . But when I connect to "myurl" I keep getting the same error. I'm sure the problem is that the server receives a GET and not a POST.
  10. POST by Sockets

    alright, so , I dont want to have to keep asking you one question at a time, but did you then try your URL? If so, do you still connect? etc, etc. etc. Its process of elimination here....
  11. POST by Sockets

    Yes, i get the "Socket connected" message
  12. POST by Sockets

    comment out your try except block and let the OnError event test for error replace your url with the test url: wss://echo.websocket.org Do you get a "Socket Connected!" message?
  13. POST by Sockets

    Hi. I have moved events to InitializeObject procedure TForm1.InitializeObject; FSocket := TW3WebSocket.Create; FSocket.OnOpen:= Procedure (Sender:TW3WebSocket) begin showmessage('Socket connected'); //Sender.Write("your data here"); end; FSocket.OnClosed:=procedure (Sender:TW3WebSocket) begin showMessage("Socket disconnected"); end; FSocket.OnMessage:= Procedure (Sender: TW3WebSocket; Message: TWebSocketMessageData) begin showMessage("Data received:" + Message.mdText); end; FSocket.OnError:= procedure (Sender: TW3WebSocket; const Error: JEvent) begin showMessage("Error"); end; and execute this code in a button click try FSocket.Connect('ws://192.168.1.170:8085/api/myurl') {,[],nil);} except On E : Exception do showMessage(E.Message); end; FSocket.Write(jso.ToJson); the program never shows the connected message ("'Socket connected"). The log show this: WebSocket connection to 'ws://192.168.1.101/api/myurl' failed: Error during WebSocket handshake: Unexpected response code: 200 [line #652] or WebSocket connection to 'ws://192.168.1.170:8085/api/myurl' failed: Error during WebSocket handshake: net::ERR_CONNECTION_CLOSED [line #652] Remember that the server waits for a POST request but receives a GET on FSocket.Connect(). The error has to occur because of this, I think
  14. POST by Sockets

    You did not say whether you got an error, whether or not you know you were connected, or what your jso to Json looks like Did you use your socket open event to test for a connection? FSocket.OnOpen:= Procedure (Sender:TW3WebSocket) begin writeln("Socket connected"); //Sender.Write("your data here"); end; what about your on error event? Did you get an error at all? are you handling the message event?
  15. POST by Sockets

    I used both: FSocket.Write(jso.ToString); //try this FSocket.Write(jso.ToJson); //and this with the same result
  16. NodeJS and HTTPS

    Javascript doesnt use a VMT, it is based on prototypes which works differently (object in javascript is more like a b-tree node, that in turn can contain any number of sub nodes or name/value pairs). Our model comes on the side of this, and we bypass all the cloning JS developers have to deal with. If you look at the compiled code, you will see that all methods has a hidden "self" parameter. A VMT means that the data of the object and the methods are decoupled, and that the compiler operates with a method-table. Normally in a binary executable, the VMT is maintained at runtime. But since JavaScript is a written, source based language - the VMT is used at compile time to link up the symbols. The reason this is powerful is because it allows inheritance and re-use of existing methods without copying. JavaScript forces you to clone everything (prototypes) which limits how inheritance is dealt with by JS coders (not too elaborate, usually ad-hoc "clone my ancestor" and thats it). Our model dont need cloning. Since we ship the instance data in as the "self" param, we are able to re-use existing methods directly. In our model only the instance data is created and passed around, not the methods and everything else. Had this been a compiled language then yes, then the VMT would be implemented inside the code as part of TObject (actually, just beneath the surface of TObject). But since JS is text based we link up symbols during the compilation. You can watch how this works if you run a program in the browser and set some breakpoints, then inspect the "self" parameter directly: You could say that the JS instance both is a VMT and is sculpted from a VMT. But the sculpting is naturally applied in JS. TObject doesnt magically shape itself so to speak.
  17. POST by Sockets

    You probably want to use the ToJSON() function
  18. POST by Sockets

    Ok, now the socket connection is established. But the server is waiting for a POST with a JSON. I have tried this var jso := TJSonObject.Create; jso.AddOrSet("Tabla", "Login" ); jso.AddOrSet("Valor", trim(edCodigo.Text)); jso.AddOrSet("Clave", trim(edClave.Text)); try FSocket.Connect('ws://192.168.1.170:8085/api/myurl',[],nil); except On E : Exception do showMessage(E.Message); end; FSocket.Write(jso.ToString); //try this FSocket.Write(jso.ToJson); //and this The server receive this: GET /api/myurl HTTP/1.1 Host: 192.168.1.170:8085 Connection: Upgrade Pragma: no-cache Cache-Control: no-cache Upgrade: websocket Origin: http://192.168.1.101:8090 Sec-WebSocket-Version: 13 User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36 Accept-Encoding: gzip, deflate Accept-Language: en-US,en;q=0.8 Sec-WebSocket-Key: SBmnhjj2RfnqapogFofwKA== Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits no json received
  19. W3webSocket

    I have deleted all the folders and saved the license. I have unzipped the zip file and run smartupdate. The only available channel was ALPHA and it has been updated to 2.9.9.125. I have run smartupdate again. The only channel was still ALFA. I modified the file Settings.ini and changed the channel to BETA and re-executed. 12 files have been updated and the version is now 3.0.0.209. I have run again and it still did not work. BUT, I have captured the exception and the error was in the protocol: the address http: // xxxx was not valid. I changed to ws: // xxx and it works (nothing to do with the rtl).
  20. W3webSocket

    Mine runs fine! See my code below. If yours does not work, you need to uninstall and re-install. First , Make sure you first save your projects folder (any work that is not part of SMS install) and your license (user.lic) file Next. Uninstall any versions you have installed AND/OR remove any old install locations delete all remaining occurrences of C:\Program Files (x86)\Smart Mobile Studio C:\users\<username>\My Documents\Smart Mobile Projects C:\ProgramData\The Smart Company\Smart Mobile Studio Next Re-install using : http://smartmobilestudio.com/alpha.zip (just unzip folder) Next Run the SmartUpdate.exe unit Form1; interface uses W3C.DOM, System.Types, System.Types.Convert, System.Objects, System.Time, SmartCL.Net.websocket, SmartCL.System, SmartCL.Time, SmartCL.Graphics, SmartCL.Components, SmartCL.FileUtils, SmartCL.Forms, SmartCL.Fonts, SmartCL.Theme, SmartCL.Borders, SmartCL.Application, SmartCL.Controls.Button; type TForm1 = class(TW3Form) procedure W3Button1Click(Sender: TObject); private {$I 'Form1:intf'} FSocket : TW3WebSocket; protected procedure InitializeForm; override; procedure InitializeObject; override; procedure Resize; override; end; implementation { TForm1 } procedure TForm1.W3Button1Click(Sender: TObject); begin FSocket.Connect("wss://echo.websocket.org",[],nil); end; procedure TForm1.InitializeForm; begin inherited; // this is a good place to initialize components end; procedure TForm1.InitializeObject; begin inherited; {$I 'Form1:impl'} FSocket := TW3WebSocket.Create; FSocket.OnOpen:= Procedure (Sender:TW3WebSocket) begin ShowMessage("Socket connected"); Sender.Write("your data here"); end; FSocket.OnClosed:=procedure (Sender:TW3WebSocket) begin ShowMessage("Socket disconnected"); end; FSocket.OnMessage:= Procedure (Sender: TW3WebSocket; Message: TWebSocketMessageData) begin ShowMessage("Data received:" + Message.mdText); end; FSocket.OnError:= procedure (Sender: TW3WebSocket; const Error: JEvent) begin ShowMessage("Socket has errors"); end; end; procedure TForm1.Resize; begin inherited; end; initialization Forms.RegisterForm({$I %FILE%}, TForm1); end.
  21. W3webSocket

    error: Uncaught #<Object> [line #652]
  22. W3webSocket

    I have uninstalled and then instaled to update to version 3.0.0.209. the line FSocket.Connect('http://192.168.1.170:8085/api/myurl'); now compile, but donĀ“t work. show my code: type TMyJsonCommand = record Tabla: String; Codigo: String; Clave: String; end; procedure TForm1.W3Button3Click(Sender: TObject); var JsonToSend: TMyJsonCommand; begin var FSocket: TW3WebSocket; FSocket := TW3WebSocket.Create; FSocket.OnOpen:= Procedure (Sender:TW3WebSocket) begin showmessage('Socket connected'); Sender.Write("your data here"); end; FSocket.OnClosed:=procedure (Sender:TW3WebSocket) begin showMessage("Socket disconnected"); end; FSocket.OnMessage:= Procedure (Sender: TW3WebSocket; Message: TWebSocketMessageData) begin showMessage("Data received:" + Message.mdText); end; FSocket.OnError:= procedure (Sender: TW3WebSocket; const Error: JEvent) begin showmessage("Socket has errors"); end; FSocket.Connect('http://192.168.1.170:8085/api/myurl'); end;
  23. W3webSocket

    I get no error when compiling FSocket.OnError:= procedure (Sender: TW3WebSocket; const Error: JEvent) begin writeln("Socket has errors"); end;
  24. W3webSocket

    This one compiles and runs without error for me as well procedure TForm1.InitializeForm; begin inherited; // this is a good place to initialize components var FSocket: TW3WebSocket; FSocket := TW3WebSocket.Create; FSocket.Connect('http://192.168.1.170:8085/api/pedidoslogistic',[],nil) end; [INFO] Building project 'test'... [INFO] Compilation successful [227 ms] [INFO] Generating JavaScript successful [553 ms] [INFO] Linking successful [31 ms]
  25. W3webSocket

    It compiles just fine for me on 3.0.0.209 procedure TForm1.InitializeForm; begin inherited; // this is a good place to initialize components var FSocket: TW3WebSocket; FSocket := TW3WebSocket.Create; FSocket.Connect('http://192.168.1.170:8085/api/pedidoslogistic',[]); end; [INFO] Building project 'test'... [INFO] Compilation successful [166 ms] [INFO] Generating JavaScript successful [585 ms] [INFO] Linking successful [50 ms]
  26. W3webSocket

    I have not updated,I have done a new instalation with the 3.0.0.201 In the uses area: System.Types, System.Types.Convert, System.Objects, System.Time, SmartCL.System, SmartCL.Time, SmartCL.Graphics, SmartCL.Components, SmartCL.FileUtils, SmartCL.Forms, SmartCL.Fonts, SmartCL.Theme, SmartCL.Borders, SmartCL.Application, SmartCL.Controls.Label, SmartCL.Controls.EditBox, SmartCL.Controls.Button, SmartCL.Layout, System.Encoding, System.JSON, SmartCL.net.http, SmartCL.net.Rest, SmartCL.Net.websocket; I use it like that: var FSocket: TW3WebSocket; FSocket := TW3WebSocket.Create; FSocket.Connect('http://192.168.1.170:8085/api/pedidoslogistic',[]); //does not compile if i try to FSocket.Connect('http://192.168.1.170:8085/api/pedidoslogistic',[],nil); //Complile but error in execution FSocket.Connect('http://192.168.1.170:8085/api/pedidoslogistic',); //does not compile I'm missing some unit? Can not the funcions be overloaded in RTL? This code does not compile either (error with JEvent): FSocket.OnError:= procedure (Sender: TW3WebSocket; const Error: JEvent) begin writeln("Socket has errors"); end; I have not updated,I have done a new instalation with the 3.0.0.201 In the uses area: System.Types, System.Types.Convert, System.Objects, System.Time, SmartCL.System, SmartCL.Time, SmartCL.Graphics, SmartCL.Components, SmartCL.FileUtils, SmartCL.Forms, SmartCL.Fonts, SmartCL.Theme, SmartCL.Borders, SmartCL.Application, SmartCL.Controls.Label, SmartCL.Controls.EditBox, SmartCL.Controls.Button, SmartCL.Layout, System.Encoding, System.JSON, SmartCL.net.http, SmartCL.net.Rest, SmartCL.Net.websocket; I use it like that: var FSocket: TW3WebSocket; FSocket := TW3WebSocket.Create; FSocket.Connect('http://192.168.1.170:8085/api/pedidoslogistic',[]); //does not compile if i try to FSocket.Connect('http://192.168.1.170:8085/api/pedidoslogistic',[],nil); //Complile but error in execution FSocket.Connect('http://192.168.1.170:8085/api/pedidoslogistic',); //does not compile I'm missing some unit? Can not the funcions be overloaded in RTL? This code does not compile either (error with JEvent): FSocket.OnError:= procedure (Sender: TW3WebSocket; const Error: JEvent) begin writeln("Socket has errors"); end;
  27. W3webSocket

    I have not updated,I have done a new instalation with the 3.0.0.201 In the uses area: System.Types, System.Types.Convert, System.Objects, System.Time, SmartCL.System, SmartCL.Time, SmartCL.Graphics, SmartCL.Components, SmartCL.FileUtils, SmartCL.Forms, SmartCL.Fonts, SmartCL.Theme, SmartCL.Borders, SmartCL.Application, SmartCL.Controls.Label, SmartCL.Controls.EditBox, SmartCL.Controls.Button, SmartCL.Layout, System.Encoding, System.JSON, SmartCL.net.http, SmartCL.net.Rest, SmartCL.Net.websocket; I use it like that: var FSocket: TW3WebSocket; FSocket := TW3WebSocket.Create; FSocket.Connect('http://192.168.1.170:8085/api/pedidoslogistic',[]); //does not compile if i try to FSocket.Connect('http://192.168.1.170:8085/api/pedidoslogistic',[],nil); //Complile but error in execution FSocket.Connect('http://192.168.1.170:8085/api/pedidoslogistic',); //does not compile I'm missing some unit? Can not the funcions be overloaded in RTL? This code does not compile either (error with JEvent): FSocket.OnError:= procedure (Sender: TW3WebSocket; const Error: JEvent) begin writeln("Socket has errors"); end;
  28. W3webSocket

    you should have procedure Connect(URL: string; Protocols: array of string; const CB: TWebSocketCallback); procedure Connect(URL: string; Protocols: array of string); overload; procedure Connect(URL: string); overload;
  29. W3webSocket

    Update using smart update?
  1. Load more activity
×