Friday, 15 November 2019

Socket server, track individual socket connection

I'm trying to implement a very specific set of needs and I can't figure out the right way to go about it.I want a client to connect to my socket server and I want to be able to identify this client to the server via an arbitrary set of attributes, such as {'id': 'some_random_id', 'path': '/homepage', 'username: 'Chris'} etc. I will then store these attributes to act on later from the server. Then when an event comes in from that socket, I want to be able to tie it back to the same socket. Or I could trigger something on the server to say grab all users with path "/homepage" and send them a message. However, I can't figure out how to do this.Currently I'm trying to use https://www.npmjs.com/package/ws-server-wrapper and https://www.npmjs.com/package/ws-wrapper. I don't know if this would be made any simpler using regular 'ws' or upgrading to 'socket.io'. I can't seem to log any sort of identifying information via socket data, and I'm not sure if it's best/possible to add this additional data on connection or via a subsequent event.Any help would be incredibly appreciated!

Submitted November 16, 2019 at 04:23AM by ReactiveNative

No comments:

Post a Comment