static void ws_SessionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason reason) { User userObj = Server.FindClientBySessionId(session.SessionID); foreach (IUserConnection userConnection in userObj.Connections) { if (userConnection.Type == UserConnectionTypes.WebSocket) { WebSocketUserCommunication connection = (WebSocketUserCommunication)userConnection; if (connection.SessionId() == session.SessionID) { userConnection.Close(); List<IUserConnection> userConnectionList = new List<IUserConnection>(); userConnectionList.AddRange(userObj.Connections); userConnectionList.Remove(userConnection); userObj.Connections = new ReadOnlyCollection<IUserConnection>(userConnectionList); //userObj.Connections.Remove(userConnection); break; } } } if (userObj.Connections.Count <= 0) { Server.ClientList.Remove(userObj); //TODO: just do quit command instead. userObj.Save(); } //TODO: deal with multi user login? }
/// <summary> /// 输出断开连接信息 /// </summary> /// <param name="session"></param> /// <param name="reason"></param> protected override void OnSessionClosed(BsProtocolSession session, CloseReason reason) { base.OnSessionClosed(session, reason); //Common.Extensions.AddLog($"{session.LocalEndPoint.Address}:断开连接\r\n"); //Common.Extensions.AddLog($"{session.RemoteEndPoint}连接断开. 断开原因:{reason}\r\n"); _logger.Info($"{session.LocalEndPoint.Address}:断开连接\r\n{session.RemoteEndPoint}连接断开. 断开原因:{reason}"); }
static void BoxProtocolServer_SessionClosed(BoxSession session, SuperSocket.SocketBase.CloseReason value) { LogHelper.WriteLog("---------------------------------------------------------------------------------------------------"); LogHelper.WriteLog(DateTime.Now.ToString("HH:mm:ss") + "sessionid:" + session.SessionID + ";mac:" + session.CustomId); LogHelper.WriteLog(session.RemoteEndPoint.ToString() + "连接断开. 断开原因:" + value); LogHelper.WriteLog("---------------------------------------------------------------------------------------------------"); }
public static void server_SessionClosed(AppSession session, SuperSocket.SocketBase.CloseReason value) { log.Info("离开服务器\r\n"); //File.AppendAllText("D:\\111\\1.log", "~~~" + DateTime.Now.ToString() + "~~~" + session.SessionID); //ChangeText c = new ChangeText(Get); try { String name = ""; foreach (var us in ls) { if (us.sesson == session) { if (debug == true) { File.AppendAllText("c:\\log\\1.log", DateTime.Now.ToString() + us.user + "离开服务器\r\n"); } name = us.user; ls.Remove(us); break; } } } catch (Exception e) { File.AppendAllText("c:\\log\\1.log", e.ToString() + "\r\n"); } }
void myServer_SessionClosed(HansAppSession session, SuperSocket.SocketBase.CloseReason value) { foreach (var item in Gateway_SessionDic) { if (item.Value == session) { HansAppSession dd = null; Gateway_SessionDic.TryRemove(item.Key, out dd); using (RedisHashService service = new RedisHashService()) { service.SetEntryInHash("DeviceStatus", item.Key + "_13579", "");//设置离线, log.Info($"{item.Key} 离开服务器"); //网关下的所有设备状态设置为离线 using (HsfDBContext db = new HsfDBContext()) { var channelList = db.host_device.Where(t => t.devchannel == item.Key && t.deletemark == 0); foreach (var item2 in channelList) { service.SetEntryInHash("DeviceStatus", item2.cachekey, "");//设置离线 } } } } } connectCount--; Console.WriteLine($"{session.RemoteEndPoint.ToString()} 离开服务器 {connectCount} {DateTime.Now.ToString()}"); log.Info($"{session.RemoteEndPoint.ToString()} 离开服务器 {connectCount}"); //throw new NotImplementedException(); }
//断开事件 void appServer_NewSessionClosed(AppSession session, SuperSocket.SocketBase.CloseReason aaa) { Socket_LOG("服务端 失去 来自客户端的连接" + session.SessionID + aaa.ToString()); pictureBox1.Image = Properties.Resources.disconnect; var count = appServer.GetAllSessions().Count(); Console.WriteLine(count); }
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 appServer_SessionClosed(MyAppSession session, SuperSocket.SocketBase.CloseReason reason) { string ip = session.SocketSession.RemoteEndPoint.Address.ToString(); Console.WriteLine(reason.ToString()); Console.WriteLine("断开连接:" + reason); listView1.Items[ip].Remove(); }
private void server_SessionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason value) { Console.WriteLine(); Console.WriteLine("Client disconnected! Sessions counter: "); if (apps.Contains(session)) { apps.Remove(session); } }
//bağlantı kesildiğinde bu metod çalışıyor. private void OnBaglantiKoptu(WebSocketSession session, SuperSocket.SocketBase.CloseReason value) { if (this.bagliKullanicilar.Contains(session)) { this.bagliKullanicilar.Remove(session); } this.EkranaMesajYaz(string.Format("{0} kullanıcısı bağlantıyı kapattı!", session.SessionID)); this.ListBoxGuncelle(); }
void appServer_SessionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason value) { var sessions = appServer.GetSessions(b => true); foreach (var ss in sessions) { ss.Close(); } session.Send(funTools.getJsonFromHashtable(null, "0", "连接接断开!")); }
/// <summary> /// Session关闭 /// </summary> /// <param name="session"></param> /// <param name="value"></param> void protocolServer_SessionClosed(HLProtocolSession session, SuperSocket.SocketBase.CloseReason value) { //锁 lock (locker) { clientCount--; clientCount_tb.Text = clientCount.ToString(); } session.Logger.Info(GetCurrentTime() + "\r\n客户端【" + session.RemoteEndPoint + "】已经中断连接,连接数:" + clientCount.ToString() + ",断开原因:" + value + "\r\n"); session.Close(); }
void appServer_SessionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason value) { for (int i = 0; i < MAX_PLAYER; ++i) { if (players[i] != null && players[i].Session.SessionID.Equals(session.SessionID)) { players[i] = null; this.isFull = false; break; } } }
void appServer_SessionClosed(ESOPSession session, SuperSocket.SocketBase.CloseReason value) { txtMsg.Invoke(new EventHandler(delegate { txtMsg.Items.Add(string.Format("用户{0}断开链接...当前连接数:{1} ", session.Name, appServer.SessionCount)); })); var client = clients.Where(a => a.Name == session.Name).FirstOrDefault(); if (client != null) { clients.Remove(client); } // LastRequestInfo.Remove(session.Name); }
public static void server_SessionClosed(AppSession session, SuperSocket.SocketBase.CloseReason value) { try { var us = ls.Where(t => t.sesson == session).FirstOrDefault(); if (us != null) { log.Debug($"{us.user} 离开智能家居Socket服务器"); Console.WriteLine($"{us.user} 离开智能家居Socket服务器"); ls.Remove(us); } } catch (Exception e) { log.Error($"{e.Message} 离开智能家居Socket服务器"); } }
private void WsServer_SessionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason value) { try { lblWsClientConnection.Text = String.Format("{0} client connected", wsServer.SessionCount.ToString()); lblWsClientConnection.ForeColor = Color.Green; if (wsServer.SessionCount == 0) { lblWsClientConnection.Text = "Waiting client..."; lblWsClientConnection.ForeColor = Color.Orange; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void WebSocketServer_SessionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason close_Reason) { #if My_DEBUG Console.WriteLine("Entering " + System.Reflection.MethodBase.GetCurrentMethod().ToString()); #endif string ip_Address = session.RemoteEndPoint.Address.ToString(); //MessageBox.Show("Host "+ host + " requested a disconnect"); System.Collections.ObjectModel.Collection <string> keys = new System.Collections.ObjectModel.Collection <string>(); List <string> company_Names = connected_Users.Keys.ToList(); bool found = false; string required_Company_Name = ""; string required_User_Name = ""; foreach (string company_Name in connected_Users.Keys) { foreach (string user_Name in connected_Users[company_Name].Keys) { if (connected_Users[company_Name][user_Name].RemoteEndPoint.Address.ToString() == session.RemoteEndPoint.Address.ToString()) { found = true; required_Company_Name = company_Name; required_User_Name = user_Name; break; } } } if (found) { connected_Users[required_Company_Name][required_User_Name].Close(); connected_Users[required_Company_Name].Remove(required_User_Name); } if (resume_View_Server_Session != null) { if (resume_View_Server_Session.Status == SessionStatus.Healthy) { resume_View_Server_Session.SendResponse("Base_Connection_Disconnected|^|" + ip_Address); } } #if My_DEBUG Console.WriteLine("Exiting " + System.Reflection.MethodBase.GetCurrentMethod().ToString()); #endif }
void wsServer_SessionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason value) { WebSocketServerChannel channel = null; lock (this.channelMap) { if (!this.channelMap.TryGetValue(session, out channel)) { // log logger.ErrorFormat("session[{0}] not found in channel map", session.RemoteEndPoint); Console.WriteLine("session not found!!!"); return; } this.channelMap.Remove(session); } //channel.ReceiveData(null); channel.Close(); // log logger.InfoFormat("channel[{0}] colsed. total channel number [{1}]", session.RemoteEndPoint, this.channelMap.Count); }
static void HLProtocolServer_SessionClosed(HLProtocolSession session, SuperSocket.SocketBase.CloseReason value) { Console.WriteLine(session.RemoteEndPoint + "连接断开. 断开原因:" + value); }
void app_SessionClosed(UdpSession session, SuperSocket.SocketBase.CloseReason value) { LogHelper.WriteLog("链接断开:" + session.SessionID); }
private static void WsServer_SessionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason value) { Console.WriteLine("SessionClosed"); }
protected override void OnSessionClosed(SuperSocket.SocketBase.CloseReason reason) { Logger.InfoFormat("AppSession.OnSessionClosed() reason:'{0}'", reason); base.OnSessionClosed(reason); }
private static void WsServer_SessionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason value) { //throw new NotImplementedException(); Console.WriteLine("SessionClosed"); }
void appServer_SessionClosed(AppSession session, SuperSocket.SocketBase.CloseReason value) { Login = false; Game.Instance.CoreTimer.StopWebTimer(); session.Send("服务已关闭"); }
public override void Close(SuperSocket.SocketBase.CloseReason reason) { Logger.InfoFormat("AppSession.Close() reason:'{0}'", reason.ToString()); base.Close(reason); }
private void Server_SessionClosed(MsgPackSession session, SuperSocket.SocketBase.CloseReason value) { hall.OnDisconnected(session, value); }
/// <summary> /// 会话断开事件处理代码 /// </summary> /// <param name="appSession"></param> public void appServer_SessionClosed(ChatsSession appSession, SuperSocket.SocketBase.CloseReason closeReason) { ShowMsg(string.Format("用户[{0}]退出登录,原因:{1}", appSession.UserName, closeReason.ToString())); UpdateConnection(); }
void appServer_SessionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason value) { this.listBox1.Items.Add(value.ToString()); session.Close(); }
/// <summary> /// Unity客户端连接断开 /// </summary> public void appServerSessionClosed(AppSession session, SuperSocket.SocketBase.CloseReason value) { NetEventQueue.Enqueue( new NetEvent(ENetEvent.Disconnected, "") ); }
public void server_ConnectionClosed(WebSocketSession session, SuperSocket.SocketBase.CloseReason reason) { syncControl.Invoke(closedDelegate); }