Ejemplo n.º 1
0
        /// <summary>
        /// 大厅服准备关闭
        /// </summary>
        static public void OnCloseLSBefore(GameSession session)
        {
            var lobbySs = ServerSsMgr.GetLobbySession();

            if (lobbySs != null && lobbySs.SessionId == session.SessionId)
            {
                Console.WriteLine("大厅服断开连接");
                ServerSsMgr.SetLobbySession(null);
                ServerSsMgr.DelSession(session);
            }
        }
Ejemplo n.º 2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /////////////////////////////////////////////////////大厅服/////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// 是否存在大厅服
        /// </summary>
        static public bool IsExistLS()
        {
            var lobbySs = ServerSsMgr.GetLobbySession();

            if (lobbySs != null)
            {
                if (lobbySs.IsHeartbeatTimeout)
                {
                    ServerSsMgr.SetLobbySession(null);
                    ServerSsMgr.DelSession(lobbySs);
                }
            }
            return(ServerSsMgr.GetLobbySession() != null);
        }
Ejemplo n.º 3
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /////////////////////////////////////////////////////其它///////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// 其它服断开处理
        /// </summary>
        /// <param name="session"></param>
        public static void OnOtherServerDisconnected(GameSession session)
        {
            string serverSid = session.SessionId;

            do
            {
                var serverInfo = sConnectServerSet.Find(m => m.CSSid == serverSid);
                if (serverInfo != null)
                {
                    Console.WriteLine("连接服断开连接,ServerId:{0},剩余:{1}", serverInfo.ServerId, sConnectServerSet.FindAll(false).Count - 1);
                    sConnectServerSet.Delete(serverInfo);
                    break;
                }
                if (ServerSsMgr.GetLobbySession() != null &&
                    ServerSsMgr.GetLobbySession().SessionId == session.SessionId)
                {
                    Console.WriteLine("大厅服断开连接");
                    ServerSsMgr.SetLobbySession(null);
                    break;
                }
                if (session.UserId == GlobalDefine.ServerIdType.SocialId.ToInt())
                {
                    Console.WriteLine("社交服断开连接");
                    SocialHelper.SocialSession = null;
                    break;
                }
                if (session.UserId == GlobalDefine.ServerIdType.SuperMonreyId.ToInt())
                {
                    Console.WriteLine("拉霸机服断开连接");
                    SuperMonreyHelper.SuperMonreySession = null;
                    break;
                }
                if (session.UserId == GlobalDefine.ServerIdType.WabaoziId.ToInt())
                {
                    Console.WriteLine("挖豹子服断开连接");
                    WbzServerHelper.WabaoziSession = null;
                    break;
                }
                var rsInfo = sRoomServerSet.Find(m => m.RSSid == serverSid);
                if (rsInfo != null)
                {
                    Console.WriteLine("房间服断开连接,ServerId:{0},剩余:{1}", rsInfo.ServerId, sRoomServerSet.FindAll(false).Count - 1);
                    sRoomServerSet.Delete(rsInfo);
                    break;
                }
            } while (false);
            //
            ServerSsMgr.DelSession(session);
        }
Ejemplo n.º 4
0
 private void socketLintener_DataReceived(object sender, ConnectionEventArgs e)
 {
     try
     {
         OnReceivedBefore(e);
         RequestPackage package;
         if (!ActionDispatcher.TryDecodePackage(e, out package))
         {
             return;
         }
         var session = GetSession(e, package);
         if (string.IsNullOrEmpty(package.ProxyId) && CheckSpecialPackge(package, session))
         {
             return;
         }
         package.Bind(session);
         if (!string.IsNullOrEmpty(package.ProxyId))
         {
             //转发给大厅服
             var lobbySs = ServerSsMgr.GetLobbySession();
             if (lobbySs == null)
             {
                 TraceLog.WriteError("SwitchSocketHost socketLintener_DataReceived error, lobbSs == null");
                 return;
             }
             SwitchSessionMgr.AddOrUpdateProxIdData(package.ProxyId, session.SessionId);
             JumpToLobbyServer(lobbySs, e).Wait();
         }
         else
         {
             ProcessPackage(package, session);
         }
     }
     catch (Exception ex)
     {
         TraceLog.WriteError("Received to Host:{0} error:{1}", e.Socket.RemoteEndPoint, ex);
     }
 }