C# Websocket-Sharp - how to identify clients -
i use websocket-sharp ( https://github.com/sta/websocket-sharp ) (serveur side only).
i can have many clients applications connected websocket server. each client send id (let's call client_id).
i want know websocket session related client_id.
iwebsocketsession expose id (let's call session_id).
what have tried:
firstly have storage class store each session_id client_id (a simple dictionary).
when receive message client application, store session_id , client_id in dictionary.
so when want send message sessions having client_id == xxx can use dictionary. works fine ...
but sessions temporary. client can use multiple sessions. single client, have many inputs in dictionary. when send message sessions in dictionnary having client_id == xxx, send same message same client multiple time.
my question : how register unique clients websocket-sharp ? property should use ?
edit : unique client, every 20s changes id of session. it's new session created ping.
ok find nothing, kept session_id when register new item in dictionary (session_id => client_id) have manually delete "old sessions".
this can done checking if session.state == websocketstate.open.
it's not perfect works.
Comments
Post a Comment