示例#1
0
        public async Task StartAsync()
        {
            Log.Information($"Starting on {_loginConfig.IpAddress}:{_loginConfig.Port}");
            var listener = _socketHelper.CreateListener(_loginConfig.IpAddress, _loginConfig.Port);

            while (true)
            {
                var handler = await listener.AcceptAsync();

                var packet = GetPacket(handler);
                switch (packet[0])
                {
                case LoginRequest.HeaderByte:
                    _requestHandlers[typeof(LoginRequest)].Handle(packet);
                    break;

                case MapDataRequest.HeaderByte:
                    _requestHandlers[typeof(MapDataRequest)].Handle(packet);
                    break;

                default:
                    Log.Warning("Unknown packet");
                    break;
                }
                handler.Shutdown(SocketShutdown.Both);
                handler.Close();
            }
        }
示例#2
0
        public async Task StartAsync()
        {
            LogInfo($"Starting on {_mapConfig.IpAddress}:{_mapConfig.Port}");
            var listener = _socketHelper.CreateListener(_mapConfig.IpAddress, _mapConfig.Port);

            while (true)
            {
                var handler = await listener.AcceptAsync();

                HandleMapRequest(handler);
            }
        }