Example #1
0
 /// <summary>
 /// 删除一个连接
 /// </summary>
 /// <param name="endPoint"></param>
 public void RemoveSClient(string endPoint)
 {
     if (m_clientDic.ContainsKey(endPoint))
     {
         m_clientDic.Remove(endPoint);
         ServerLog.Log(string.Format("{0}Has Lost Link", endPoint));
     }
 }
Example #2
0
 /// <summary>
 ///更新某玩家
 /// </summary>
 /// <param name="info"></param>
 /// <returns></returns>
 public bool UpdateUserInfo(DBUserInfo info)
 {
     try
     {
         DBMgr.MInstance.DBSession().Update(info);
         return(true);
     }
     catch (Exception exp)
     {
         ServerLog.Log(string.Format("Update Wrong:{0}", exp.Message));
         return(false);
     }
 }
Example #3
0
        public void SendMsg(string endPoint, ProtocolEnum protocolId, object data)
        {
            ServerClient client = GetSClient(endPoint);

            if (client != null)
            {
                try
                {
                    client.SendMsg(protocolId, data);
                }
                catch (Exception exp)
                {
                    ServerLog.Log(string.Format("Send To :{0}, Error:{1}", endPoint, exp.Message));
                }
            }
        }
Example #4
0
        public void InitServer()
        {
            try
            {
                m_listener = new TcpListener(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 12000));
                m_listener.Server.NoDelay = true;
                m_listener.Start(10);

                ServerLog.Log("Server Start OK!");
                m_listener.BeginAcceptTcpClient(new AsyncCallback(AsyncListen), m_listener);
            }
            catch (Exception exp)
            {
                Console.WriteLine("Wrong When AcceptTcp Client:{0}", exp.Message);
            }
        }
Example #5
0
 /// <summary>
 /// 删除某项
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public bool DeleteUserInfo(int id)
 {
     try
     {
         DBMgr.MInstance.DBSession().Delete(new DBUserInfo()
         {
             MUserId = id
         });
         return(true);
     }
     catch (Exception exp)
     {
         ServerLog.Log(string.Format("Delete Wrong:{0}", exp.Message));
         return(false);
     }
 }
Example #6
0
        static void Main(string[] args)
        {
            new NetMsgDispatch();
            new ProtocolMgr().RegAssembly(typeof(STC_UserInfo).Assembly);

            new DBMgr();
            DBMgr.MInstance.onInitDBSuccess = delegate()
            {
                ServerLog.Log("DataBase Initialize OK");
                new GameModuleMgr();
                GameModuleMgr.MInstance.AddModule(new LoginModule());
                GameModuleMgr.MInstance.AddModule(new HeartBeatModule());

                new UserMgr();
                new ServerNet();
            };
            DBMgr.MInstance.InitializeDB("127.0.0.1", 3306, "database_test", "bc", "123456");

            Console.ReadKey();
        }