/// <inheritdoc/> public void Regenerate() { if (_session != null) { _sessionManager.Delete(_context, _session.Id); } EnsureSessionManagerExists(); _session = _sessionManager.Create(_context); }
protected void CreateNewSession(RiotUser riotUser) { if (mSession != null) { mSessionManager.Delete(mSession.SessionId); } mSession = mSessionManager.Create(Guid.NewGuid(), riotUser); Response.Cookies.Append(SessionIdCookieName, mSession.SessionId.ToString()); }
public WebSocketService(int port, IRouter <T> router, ISessionManager <T> sessions) { server = new WebSocketServer(); server.NewMessageReceived += (sock, message) => { T session = null; try { session = Session(sock); if (session != null) { router.Route(message, session); } else { sock.Close(); } } catch (Exception ex) { if (session != null) { router.Error(ex, session); } sock.Close(); } }; server.SessionClosed += (sock, message) => { T session = Session(sock); if (session != null) { sessions.Remove(session); session.Close(); } }; server.NewSessionConnected += (sock) => { var session = sessions.Create(new WebSocketChannel(sock)); if (session == null) { sock.Close(); } else { sock.Items[SessionKey] = session; } }; if (!server.Setup(new ServerConfig { Port = port, MaxConnectionNumber = 100000 }) || !server.Start()) { WebSocketException.ThrowServerError("Server setup failed. Turn on SuperWebSockets logging for more details."); } }