private static void MqServer_SessionClosed(MQProtocolSession session, SuperSocket.SocketBase.CloseReason value) { try { if (session.TopicMode.TopicDic.Count > 0) { foreach (var r in session.TopicMode.TopicDic.Keys) //room { foreach (var t in session.TopicMode.TopicDic[r].Keys) //topic { foreach (var g in session.TopicMode.TopicDic[r][t]) //tag { if (mqServer.TopicMessageQueueDict.ContainsKey(r) && mqServer.TopicMessageQueueDict[r].ContainsKey(t) && mqServer.TopicMessageQueueDict[r][t].ContainsKey(g)) { mqServer.TopicMessageQueueDict[r][t][g].Remove(session); } mqServer.TopicMessageQueueDict[r][t][g].TrimExcess(); } } } } } catch (Exception e) { mqServer.Logger.Error(session, new Exception("移除主题字典失败", e)); } mqServer.Logger.Info(session.RemoteEndPoint.ToString() + " closed. reason:" + value); }
void ws_SessionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason value) { Console.WriteLine("{0:HH:MM:ss} 与客户端:{1}的会话被关闭 原因:{2}", DateTime.Now, GetSessionName(session), value); var msg = string.Format("{0:HH:MM:ss} {1} 离开聊天室", DateTime.Now, GetSessionName(session)); SendToAll(session, msg); }
public void CloseClient(WebSocketSession session, SuperSocket.SocketBase.CloseReason reason) { if (this.InvokeRequired) { this.BeginInvoke( new CloseClient_Delegate(CloseClient), new Object[] { session, reason }); return; } try { string str = ""; string sessionid = session.SessionID; MyWebSocketSession oldSessoin = sessionList.Find(delegate(MyWebSocketSession temp) { return(temp.sessionid == session.SessionID); }); if (oldSessoin != null) { sessionList.Remove(oldSessoin); } //this.dataGridView1.DataSource = new BindingList<MyWebSocketSession>(sessionList); str += session.SessionID + "-离开," + reason.ToString(); //增加连接记录; OnAddLogEvent("连接", str); } catch (Exception exp) { //捕捉错误; //this.CatchException(exp); } }
protected override void OnSessionClosed(SuperSocket.SocketBase.CloseReason reason) { //let the users know that the player isn't there anymore TheGame.Instance.gameObjects.RemoveGameObject(Player); base.OnSessionClosed(reason); }
private void WebSocket_SessionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason value) { if (mClients.Any(it => it.socket == session)) { mClients.Remove(mClients.First(it => it.socket == session)); } }
private void SessionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason value) { Console.WriteLine("Session [" + session.Host + "] closed due to reason " + value + "(start: " + session.StartTime + ")"); aClientTimers[session].Stop(); aClientTimers.TryRemove(session, out _); }
/// <summary> /// rewrite session on close. /// </summary> /// <param name="session"></param> /// <param name="value"></param> private void WsServer_SessionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason value) { um("SessionClosed, ID:" + session); //remove seesion from list currentsession = null; }
private void Server_SessionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason value) { WebSocketSession oldSession; _sessions.TryRemove(session.SessionID, out oldSession); StatusMessageAction.Invoke(null, false, $"Session closed: {session.SessionID}"); StatusAction(ServerStatus.SessionCount, _sessions.Count); }
private void WebSocketServer_SessionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason value) { PermissionLevel level; while (!clients.TryRemove(session.SessionID, out level)) { Thread.Sleep(1); } }
private void SocketServer_SessionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason value) { lock (obj) { sessionList.Remove(session); sendSessionList.Remove(session); } RefreshSessionList(); AppendInfo($"【{session.RemoteEndPoint}】: 退出会话"); }
/// <summary> /// 关闭连接 /// </summary> /// <param name="session">连接信息</param> /// <param name="reason">关闭原因</param> private void SessionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason reason) { //关闭连接 var userName = GetUserInfo(session).UserId; if (ConnectionPool.ContainsKey(userName)) { ConnectionPool[userName].Remove(session); } }
private void Server_SessionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason value) { if (session.Items.ContainsKey(1)) { Interlocked.Decrement(ref _manager_login_c); } session.Items.Clear(); this.PutLogQueue("Websocket Session Closed!", ConsoleColor.DarkYellow); }
private void AppServer_SessionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason value) { Console.WriteLine("Session disconnected"); if (appServer.SessionCount == 0) { Console.WriteLine("No active sessions, exiting"); System.Threading.Thread.Sleep(1000); Environment.Exit(0); } }
private void MyWebSocketServer_SessionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason value) { lock (obj) { var removeSession = MyAppServer.Sessions.FirstOrDefault(s => s.WebSocketSession != null && s.WebSocketSession == session); if (removeSession != null) { MyAppServer.Sessions.Remove(removeSession); } MyAppServer.Sessions.RemoveAll(s => s.WebSocketSession != null && !s.WebSocketSession.Connected); } }
/// <summary> /// indicates WebSocket session closed /// </summary> /// <param name="session">WebSocket session object</param> /// <param name="value">reason</param> void OnSessionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason value) { try { lock (DataServer.MessageRouter.gMessageRouter) { DataServer.MessageRouter.gMessageRouter.RemoveSession(session.SessionID); } } catch { } }
//切断 static void HandleServerSessionClosed(SuperSocket.WebSocket.WebSocketSession session, SuperSocket.SocketBase.CloseReason e) { if (frm != null) { frm.session_ary.Remove(session.SessionID); frm.Invoke((MethodInvoker) delegate() { frm.add_log(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), "切断"); }); } }
/// <summary> ///由用户断开连接的时候 /// </summary> /// <param name="session"></param> /// <param name="value"></param> void ws_SessionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason value) { showLog("客户端" + session.RemoteEndPoint.ToString() + ":断开成功"); try { var secretKey = dic[session]; DbConnectionMySQL.ExecuteNonQuery(DbConnectionMySQL.Conn, CommandType.Text, "update game set Online='否' where secretKey='" + secretKey + "'", null); SendToAllPosition(secretKey, 0.0f, 0.0f, 0, "remove"); } catch (System.Collections.Generic.KeyNotFoundException) { dic.Remove(session); showData(); } }
void CPWebSocketServer_SessionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason value) { try { foreach (var subscriptions in this.Subscriptions) { var subscribers = (List <SubscriberConstrains>)subscriptions.Value; subscribers.RemoveAll(item => item.SubsciberId == session.SessionID); } } catch (Exception ex) { log.Error("Error on SessionClosed ", ex); } //remove subscriber resources }
private void Disconnect(WebSocketSession session, SuperSocket.SocketBase.CloseReason value) { GamePlayer gamePlayer = getGamePlayer(session); Console.WriteLine("player " + gamePlayer.player.name + " disconnected"); if (gamePlayer != null) { gamePlayer.game.removePlayer(gamePlayer); if (gamePlayer.game.isEmpty()) { gamePlayer.game = null; game = null; } } sessionPlayers[session.SessionID] = null; }
private void Server_SessionClosed(Session session, SuperSocket.SocketBase.CloseReason value) { if (CustomDic.Keys.Contains(session.RemoteEndPoint.ToString())) { string StrCustom = session.RemoteEndPoint.ToString(); CustomDic.Remove(StrCustom); if (InvokeRequired) { Invoke(MyShowInfoDelgete, new object[] { StrCustom, false }); } else { listBox1.Items.Remove(StrCustom); } } }
/// <summary> /// 会话关闭 /// </summary> /// <param name="session"></param> /// <param name="value"></param> private void server_SessionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason value) { string datetimes = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"); //删除电脑用户 for (int ii = DNusers.Rows.Count - 1; ii >= 0; ii--) { if (!String.IsNullOrEmpty(DNusers.Rows[ii]["id"].ToString()) && session.SessionID == DNusers.Rows[ii]["id"].ToString()) { DNusers.Rows[ii]["zt"] = "离线"; //DNusers.Rows.RemoveAt(ii); this.listBox1.Items.Add(string.Format("{0}", DNusers.Rows[ii]["name"].ToString() + "已离线 " + datetimes)); //listBox滚动条一直显示最后一条 this.listBox1.TopIndex = this.listBox1.Items.Count - (int)(this.listBox1.Height / this.listBox1.ItemHeight) + 2; } } }
protected override void AppServerSessionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason value) { FileLogger.Instance.LogMessage("Client Disconnected. IP " + session.RemoteEndPoint.Address + " Port " + session.RemoteEndPoint.Port.ToString()); FileLogger.Instance.LogMessage("Reason " + value); FileLogger.Instance.LogMessage("Web Socket Check Status " + wsCheckComplete); if (wsCheckComplete) { if (ClosingMethodReceived != null) { ClosingMethodReceived(this, MethodReceivedEventArgs.Empty); } } // The first connection to the socket will be always from the Launcher. // Therefore we should not close the native wrapper aftert the first connection. For subsequent connections, // the native wrapper will be closed when the connection is closed. wsCheckComplete = true; }
private static void WsServer_SessionClosed(WebSocketSession _session, SuperSocket.SocketBase.CloseReason _value) { _session.Send("Your session has now been closed, thanks for participating!" + "The reason for the stream closing is the following: " + _value.ToString()); for (int i = 0; i < m_NrOfClientsConnected; i++) { if (m_WsSessions[i].ToString() == _session.SessionID) { m_WsSessions[i] = m_WsSessions[m_NrOfClientsConnected - 1]; WebSocketSession[] tempArr = new WebSocketSession[m_NrOfClientsConnected]; for (int x = 0; x < m_NrOfClientsConnected - 1; x++) { tempArr[x] = m_WsSessions[x]; } m_WsSessions = tempArr; } } m_NrOfClientsConnected--; }
private void Disconnect(WebSocketSession session, SuperSocket.SocketBase.CloseReason value) { GamePlayer gamePlayer = getGamePlayer(session); //Console.WriteLine("player " + gamePlayer.player.name + " disconnected"); if (gamePlayer != null) { gamePlayer.game.gamePlayers.removePlayer(gamePlayer); game.mover.removeObserver(gamePlayer); if (gamePlayer.game.gamePlayers.isEmpty()) { gamePlayer.game = null; game = null; } else { game.mover.observers.ForEach(x => x.PlayerListChange(game)); } } sessionPlayers[session.SessionID] = null; }
/// <summary> /// 会话关闭 /// </summary> /// <param name="session"></param> /// <param name="value"></param> private void server_SessionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason value) { //删除电脑用户 for (int ii = DNusers.Rows.Count - 1; ii >= 0; ii--) { if (!String.IsNullOrEmpty(DNusers.Rows[ii]["id"].ToString()) && session.SessionID == DNusers.Rows[ii]["id"].ToString()) { DNusers.Rows[ii]["zt"] = "离线"; //DNusers.Rows.RemoveAt(ii); } } //删除手机用户 for (int i = users.Rows.Count - 1; i >= 0; i--) { if (!String.IsNullOrEmpty(users.Rows[i]["id"].ToString()) && session.SessionID == users.Rows[i]["id"].ToString()) { users.Rows[i]["zt"] = "离线"; //users.Rows.RemoveAt(i); } } }
private void Server_SessionClosed(ClientSession session, SuperSocket.SocketBase.CloseReason value) { Exec(() => { _server.ClientSessions.Remove(session); string sessionID = session.SessionID; if (_dic0x01.ContainsKey(session)) { _dic0x01.TryRemove(session, out Data0x01 xe); } if (_dic0x09.ContainsKey(session)) { _dic0x09.TryRemove(session, out Data0x09 data0x09); } RemoveRowGridView(sessionID); dtgXe.CheckedHeaderGridView(); }); }
private static void WsServer_SessionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason value) { byte[] msg; if (gameSessions.Where(g => g.PlayerSessionIDs.Contains(session.SessionID)).Any()) { var games = gameSessions.Where(g => g.PlayerSessionIDs.Contains(session.SessionID)).ToList(); int gameIndex; int playerIndex; int opponentIndex; foreach (GameSession g in games) { gameIndex = gameSessions.IndexOf(g); playerIndex = Array.IndexOf(gameSessions[gameIndex].PlayerSessionIDs, session.SessionID); if (playerIndex == 0) { opponentIndex = 1; } else { opponentIndex = 0; } gameSessions[gameIndex].PlayersReady[playerIndex] = false; gameSessions[gameSessions.IndexOf(g)].PlayerSessionIDs[playerIndex] = ""; if (g.GameState != GameState.Lost && g.GameState != GameState.Won) { gameSessions[gameSessions.IndexOf(g)].GameState = GameState.Interrupted; } if (wsServer.GetAllSessions().Where(s => s.SessionID.Equals(g.PlayerSessionIDs[opponentIndex])).Any()) { msg = Encoding.UTF8.GetBytes("Other player disconnected"); wsServer.GetAppSessionByID(g.PlayerSessionIDs[opponentIndex]).Send(msg, 0, msg.Length); } } } Console.WriteLine(session.SessionID + " closed session"); }
public void WebSocketServer_SessionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason close_Reason) { }
/// <summary> /// 会话关闭 /// </summary> /// <param name="session"></param> /// <param name="value"></param> private void server_SessionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason value) { }
void webSocketServer_SessionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason value) { log.Debug("removing web socket session : " + value.ToString()); lock (webSocketSessions) webSocketSessions.Remove(session); }