Closed murshid1988 closed 6 years ago
Do you have a solution ?? I too have this same issue, I want to connet only after login and when my server provides with a token to pass to my socket url
@gaurav112
Yes, basically when the app initializing I check if the token in my storage is valid with the server, if it threw an error I run socket.disconnect();
. If I got a success response I run socket.connect();
Also in the login method, I received a success response only I run socket.connect();
. Else socket.disconnect();
Also, I do socket.disconnect()
when he logs out. In the server, I maintain a pending message feature associated with the ID. So when the particular person comes online I deliver the messages that were sent to him when he was offline.
Hi,
So this is the thing. I would like to pass the userID as an
option
while connecting to socket server. So I won't be able to implement this inapp.module.ts
. So, I tried creating a separateprovider
extendingsocket
. But there also you have to do it in theconstructor()
, where I am not able to do anything else such as getting the id from another provider since I have to usesuper()
and can't usethis.
.What are my options?