Jump to content

Websocket parameters


Recommended Posts

 

 

I Have looked at the websocketserver demo in SMS..but how can i pass parameters from websocket client request?

 for example on stackoverflow :

 

 

CLIENT -
var ws = new WebSocket('ws://localhost:1234/?id=1&name=foo');

SERVER -

const url = require('url');

wss.on('connection', function connection(ws, req) {
  console.log(url.parse(req.url, true).query); // { id: '1', name: 'foo' }
});

 

How can i translate this in SMS? can someone point me in the right direction??

 

Mabe it is real simple in SMS..but i'm new to websockets.

 

Mike

 

 

 

Link to post
Share on other sites
  • Administrators

I had a quick look at SmartNJ.Server.WebSocket.pas. It currently does this:

  // catch and cache remote URL
  if (request) then
  begin
    if (request.connection) then
      NJSocket.RemoteAddress := request.connection.remoteAddress;
  end;

Maybe this could be changed to:

  // catch and cache remote URL
  if (request) then
  begin
    if (request.connection) then begin
      NJSocket.RemoteAddress := request.connection.remoteAddress;
      NJSocket.RemoteUrl := request.url;
    end;
  end;

After that you could parse the parameters from RemoteUrl.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...