Пример #1
0
        private void HandleResume()
        {
            // handle a "resume" request from the client

            // get the sessionId that the client just asked us to resume
            string line       = reader.ReadLine();
            ulong  resumeThis = ulong.Parse(line);

            Console.WriteLine("SDCC.HandleResume() - Session ID to resume: " + line);

            try
            {
                // if we don't have a session open currently for this client...
                if (sessionId == 0)
                {
                    // try to resume the session in the session table
                    if (sessionTable.ResumeSession(resumeThis))
                    {
                        // if success, remember the session that we're now using and send accepted to client
                        sessionId = resumeThis;
                        SendAccepted(sessionId);
                        Console.WriteLine("SDCC.HandleResume() - Resumed session: " + sessionId.ToString());
                    }
                    else
                    {
                        // if failed to resume session, send rejectetd to client
                        SendRejected("Unable to resume session");
                        Console.WriteLine("SDCC.HandleResume() - Unable to resume session: " + sessionId.ToString());
                    }
                }
                else
                {
                    // error! we already have a session open
                    SendError("Session already open, cannot resume!");
                    Console.WriteLine("SDCC.HandleResume() - Session already open!");
                }
            }
            catch (SessionException se)
            {
                SendError(se.Message);
            }
            catch (Exception ex)
            {
                SendError(ex.Message);
            }
        }
Пример #2
0
        private void HandleResume()
        {
            // handle a "resume" request from the client

            // get the sessionId that the client just asked us to resume
            var resumeSessionId = ulong.Parse(reader.ReadLine());

            Console.WriteLine($"[{clientThread.ManagedThreadId.ToString()}] Client asked to resume session {resumeSessionId}");

            try
            {
                // if we don't have a session open currently for this client...
                if (sessionId == 0)
                {
                    // try to resume the session in the session table
                    // if success, remember the session that we're now using and send accepted to client
                    if (sessionTable.ResumeSession(resumeSessionId))
                    {
                        sessionId = resumeSessionId;
                        SendAccepted(sessionId);
                    }
                    // if failed to resume session, send rejectetd to client
                    else
                    {
                        SendRejected("Invalid session id");
                    }
                }
                else
                {
                    // error! we already have a session open
                    SendError("Session already open, cannot resume!");
                }
            }
            catch (SessionException se)
            {
                SendError(se.Message);
            }
            catch (Exception ex)
            {
                SendError(ex.Message);
            }
        }