예제 #1
0
 public TcpSession(TcpService s, TcpClient c, long id)
 {
     client   = c;
     service  = s;
     Id       = id;
     sendList = new BufferBlock <SendMsg>();
     endPoint = client.Client.RemoteEndPoint;
 }
예제 #2
0
        static void Main(string[] args)
        {
            var service = new TcpService();

            service.registerMsg(1, onCron);
            service.startListen("127.0.0.1", 9999, connectCallback, disConnectCallback);

            while (true)
            {
                Thread.Sleep(1000);
            }
        }
예제 #3
0
        public MainService(Mode mode, Protocol protocol)
        {
            instance  = this;
            mTcp      = new TcpService(ServerConfig.TCP_PORT);
            mMode     = mode;
            mProtocol = protocol;

            if (mProtocol == Protocol.KCP)
            {
                mKcp = new KcpService(ServerConfig.UDP_PORT);
            }
            else
            {
                mUdp = new UdpService(ServerConfig.UDP_PORT);
            }

            mUserManager   = new UserManager();
            mMatchManager  = new MatchManager();
            mBattleManager = new BattleManager();

            Debug.Log(string.Format("Server start success,mode={0} ip={1} tcp port={2} udp port={3}",
                                    mMode.ToString(), GetLocalIP(), ServerConfig.TCP_PORT, ServerConfig.UDP_PORT), ConsoleColor.Green);
        }
예제 #4
0
 public TcpService(int port) : base(IPAddress.Any, port)
 {
     instance = this;
     mPort    = port;
 }