Jump to content


  • Content count

  • Joined

  • Last visited

  1. Websocket server

    You're definitely right for the json package. Done in output directory: npm install websocket This is the actual message, with the % (yes strange...) I've changed the port without success. Note that I have no problem with other WebServers. Has some body been able to test my code?
  2. Layout Bug?

    It works if ou use 2 layout objects (like in sample demo 4): fLayoutCenter := Layout.Client( [Layout.Right(Layout.Width(75), fRightBar), Layout.Client(fBody)]); fLayout:= Layout.Client( [Layout.Top(Layout.Height(50), fHeader), Layout.Client(Layout.Width(75), fLayoutCenter), Layout.Bottom(fFooter)] );
  3. Websocket server

    I forgot the error message:
  4. Websocket server

    I'm trying to setup a Websocket server. But I have an error when starting the server. Seems I forgot something... maybe some internal http server? unit Unit1; interface type TServer = class public procedure Run; end; implementation uses NodeJS.Core, SmartNJ.Server, SmartNJ.Server.websocket, NodeJS.querystring, NodeJS.url, System.JSON, System.DateUtils, System.Types; { TServer} procedure TServer.Run; begin var serveur := TNJWebSocketServer.Create; // serveur.Path := '/'; serveur.Port := 8099; serveur.OnAfterServerStarted := procedure (sender: TObject) begin console.log('Serveur started, port:' + TNJWebSocketServer(Sender).Port.toString); end; serveur.OnClientConnected := procedure (const Sender: TNJWebSocketServer; const Socket: JWsSocket) begin console.log('Client connection'); end; serveur.Start; // <====== ERROR end; end.

    Thanks for the advice. I've read about it, and I'll definitely go this way !
  6. Array of multiple Types

    May be you can let away object notation and use a global function and centralize the casting inside. mySharedProcedure(myArray[i]); procedure mySharedProcedure(obj: TObject); begin if obj.Class is TClass1 then TClass1(obj).DoSomething else if obj.Class is TClass2 then TClass2(obj).DoSomething ... end;

    Thank you for your help! It works fine now: Response.end(params['callback'] + '("' + TString.EncodeUriComponent(repo) + '");', 'utf8');

    Hi, I'm trying to set up a "full stack" SMS C/S application as I'm definitely not fan of JS/Html. So I'm testing a NodeJS server (TNJHTTPServer) with a client app (TW3JSONP). But client side, ws.OnDataReady is never called. More, I have a "Uncaught ReferenceError: Invalid left-hand side in assignment [line #1]" Any help would be wellcome. (Code below, and project attached) Thanks /////////////// SERVEUR /////////////// procedure TServer.Run; var params: variant; repo : string; begin var serveur := TNJHTTPServer.Create; serveur.Port := 8099; // serveur.OnAfterServerStarted := procedure (sender: TObject) begin console.log("Serveur started, port:" + TNJHTTPServer(Sender).Port.toString); end; // serveur.OnRequest := procedure (Sender: TObject; const Request: TNJHttpRequest; const Response: TNJHttpResponse) begin params := querystring.parse(url.parse(Request.Url).query, '&'); repo := ''; if AnsiUpperCase(params['service'])= 'ADD' then begin repo := '{"id"=' + IntToStr(TimeToMilliseconds(Time)) + '}'; end else begin repo := '{"id"=0}'; end; Response.end(repo, 'utf8'); end; // serveur.Start; end; //////////////// CLIENT /////////////////// procedure TForm1.btnEnvoyerClick(Sender: TObject); var ws : TW3JSONP; data : string; begin ws := TW3JSONP.Create; ws.OnDataReady := procedure (const Sender: TW3JSONP; const Success: boolean) begin moReponse.Text := moReponse.Text + #13 + Sender.Data; ws.Free; end; data := Format('{"quand":"%s", "note":"%s"}', [DateToISO8601(StrToDateDef(edQuand.Text, Date)), QuotedStr(moNote.Text)] ); ws.Request('' +'service=ADD' +'&data='+data ); end; NodeApp2.zip
  9. Read and Write to Cookies

    Hi, Do you have any migration details for Cookies management? I think ASmartBook samples have not been upgraded I've added in uses: System.Widget, SmartCL.Storage, SmartCL.Cookies, SmartCL.Storage.Session, SmartCL.Storage.Local, SmartCL.Storage.Cookie But I'm stuck with "Cookies" intance output.Text := Cookies['ASmartBook-Key']; Thanks