|
Hi Kerry,
I have a question regarding connection of client connecting to server, and get all server side sessions. My understanding is that after a client connects to server. The "connections" becomes a session on server side, and is accessible by calling
GetAllSessions() of AppServer class.
If that's the case, I find the timing of calling GetAllSessions() does not seem reliable if calling it too soon.
I create client in a background thread, and server is running in main thread. This is pseudo code:
Main thread:
{
Create server;
Start client thread;
Wait client connects to server. (Use a Semaphore )
Call GetAllSessions();
...do some more work...
}
Client thread:
{
Create client with event handler to handle connection open
Open connection, and wait for the connection open event (for example, Opened += new EventHandler(webSocketClient_Opened);)
After receiving the connection open event, the signal main thread to continue (Use the Semaphore)
}
I find that GetAllSessions(); is not able to get server side session after client already confirmed connection is established. If I step into above code (slow), then GetAllSessions() is able to get
a session().
Is my understanding about the timing to call GetAllSession() correct?
Thanks.
|