示例#1
0
        public void StartListen()
        {
            string[] ip_address = ConfigurationManager.AppSettings["ServerIP"].Split(':');
            serverListener = new MsgPackServer();
            if (!serverListener.Setup(int.Parse(ip_address[1])))
            {
                AddDebugMessage("server setup failed!");
            }

            serverListener.NewSessionConnected += new SessionHandler <MsgPackSession>(Server_NewSessionConnected);
            serverListener.NewRequestReceived  += new RequestHandler <MsgPackSession, BinaryRequestInfo>(Server_NewRequestReceived);
            serverListener.SessionClosed       += new SessionHandler <MsgPackSession, SuperSocket.SocketBase.CloseReason>(Server_SessionClosed);

            if (!serverListener.Start())
            {
                AddDebugMessage("server started failed!");
            }
        }
示例#2
0
        public void StartListen()
        {
            string ip_address = ConfigurationManager.AppSettings["ServerIP"];
            string port       = ConfigurationManager.AppSettings["ServerPort"];

            serverListener = new MsgPackServer();
            var serverConfig = new SuperSocket.SocketBase.Config.ServerConfig
            {
                Port = int.Parse(port), //set the listening port
                Ip   = ip_address,
                Name = "GameServer",
                MaxConnectionNumber = 200,
                SendBufferSize      = 1024 * 4,
                ReceiveBufferSize   = 1024 * 4,
                SendingQueueSize    = 128,
                SendTimeOut         = 10000
            };

            if (!serverListener.Setup(serverConfig))
            {
                AddDebugMessage("server setup failed!");
            }

            /*
             * AddDebugMessage(serverListener.Config.SendTimeOut.ToString());
             * AddDebugMessage(serverListener.Config.SendBufferSize.ToString());
             * AddDebugMessage(serverListener.Config.SendingQueueSize.ToString());
             * AddDebugMessage(serverListener.Config.SyncSend.ToString());
             * AddDebugMessage(serverListener.Config.MaxConnectionNumber.ToString());
             * AddDebugMessage(serverListener.Config.IdleSessionTimeOut.ToString());
             */
            serverListener.NewSessionConnected += new SessionHandler <MsgPackSession>(Server_NewSessionConnected);
            serverListener.NewRequestReceived  += new RequestHandler <MsgPackSession, BinaryRequestInfo>(Server_NewRequestReceived);
            serverListener.SessionClosed       += new SessionHandler <MsgPackSession, SuperSocket.SocketBase.CloseReason>(Server_SessionClosed);

            if (!serverListener.Start())
            {
                AddDebugMessage("server started failed!");
            }
        }