public override async Task Process(LoginPacket packet, IPacketContext context)
        {
            var identityResult = await UserManager.AddLoginAsync(packet.Username, packet.Password);

            var errors      = (identityResult.Errors != null) ? identityResult.Errors.ToArray() : new string[0];
            var replyPacket = new LoginReplyPacket(identityResult.Success, errors);

            context.Sender.Send(replyPacket);

            if (replyPacket.Accepted)
            {
                var user = await UserManager.UserStorage.FindByNameAsync(packet.Username);

                var userConnection = TcpConnections.FindByEndpoint(context.Sender.EndPoint);
                userConnection.UserTag = user;

                NetPeer.OnClientConnected(user);

                this.NetPeer.Logger.LogInformation("User '{username}' authenticated ({address}).",
                                                   packet.Username, context.Sender.EndPoint.ToString());
            }
            else
            {
                this.NetPeer.Logger.LogInformation("User '{username}' failed to authenticated ({address}).",
                                                   packet.Username, context.Sender.EndPoint.ToString());
            }
        }
예제 #2
0
 public override Task Process(LogEvent packet, IPacketContext context)
 {
     
     using (var scope = ServiceScopeFactory.CreateScope())
     {
       return  scope.ServiceProvider.GetService<LogPacketHandler>().Process(packet, context);
     }
 }
예제 #3
0
        public override async Task Process(ChatPacket packet, IPacketContext packetContext)
        {
            _logger.LogDebug("I received the chat message: " + packet.Message);

            packetContext.Sender.Send(new ChatPacket
            {
                Message = "Hey, I got your message!"
            });
        }
        public override Task Process(ChatReplyPacket packet, IPacketContext context)
        {
            // TODO: Get sender User

            var message = new ChatMessage(null, "", packet.Message);

            ChatService.InvokeReceived(message);
            return(Task.CompletedTask);
        }
        public override Task Process(ChatPacket packet, IPacketContext context)
        {
            var sender = tcpConnections.FindByEndpoint(context.Sender.EndPoint);
            var user   = (TUser)sender.UserTag;

            this.netPeer.SendPacket(new ChatReplyPacket(Guid.NewGuid(), packet.Message));

            var message = new ChatMessage(user, packet.Channel, packet.Message);

            chatService.InvokeReceived(message);

            return(Task.CompletedTask);
        }
예제 #6
0
 public override Task Process(LoginReplyPacket packet, IPacketContext context)
 {
     if (packet.Accepted)
     {
         this.NetPeer.Logger.LogInformation("User is authenticated.");
         this.NetPeer.status = NetPeerStatus.Online;
     }
     else
     {
         this.NetPeer.Logger.LogWarning("Authentication Errors: {errors}",
                                        string.Join(", ", packet.Errors));
         this.NetPeer.Stop();
     }
     return(Task.CompletedTask);
 }
예제 #7
0
 public override async Task Process(BasicPacket packet, IPacketContext packetContext)
 {
     logger.LogDebug("Handling Basic Packet");
 }
예제 #8
0
 public override Task Process(PingPacket packet, IPacketContext context)
 {
     logger.LogDebug("Received a ping packet from " + context.Sender.EndPoint + " at " + packet.Time);
     return(Task.CompletedTask);
 }
예제 #9
0
 public override async Task Process(ChatPacket packet, IPacketContext packetContext)
 {
     _clientVm.Add();
     MessageBox.Show(packet.Message);
 }
        public override async Task Process(PingPacket packet, IPacketContext context)
        {
            var diff = DateTime.UtcNow.Subtract(packet.Time);

            Console.WriteLine($"Ping is {diff.Milliseconds}ms");
        }
예제 #11
0
 public async Task Handle(byte[] packet, int offset, int length, IPacketContext context)
 {
     await this.Process(this.PacketSerialiser.Deserialise <T>(packet, offset, length), context);
 }
예제 #12
0
 public async Task Handle(byte[] packet, IPacketContext context)
 {
     await this.Process(this.PacketSerialiser.Deserialise <T>(packet), context);
 }
예제 #13
0
 public override async Task Process(ClientPacket packet, IPacketContext context)
 {
     _clientVm.AddClient(packet);
 }
예제 #14
0
 public abstract Task Process(T packet, IPacketContext context);
 public override async Task Process(PlayerUpdatePacket packet, IPacketContext context)
 {
     this.logger.LogInformation("Wow some logging!");
 }
예제 #16
0
 public override async Task Process(ChatPacket packet, IPacketContext packetContext)
 {
     _msg.Content = packet.Message;
     await _msg.ShowAsync();
 }
예제 #17
0
 public override async Task Process(ChatPacket packet, IPacketContext packetContext)
 {
     _logger.LogDebug("I received the chat message: " + packet.Message);
     packetContext.Sender.Send(Encoding.ASCII.GetBytes(packet.Message));
 }
예제 #18
0
 public override async Task Process(LogEvent packet, IPacketContext context)
 {
     await _logProcessor.ProcessLog(packet);
 }
예제 #19
0
 public override async Task Process(ChatPacket packet, IPacketContext packetContext)
 {
     _logger.LogDebug("I received the chat message: " + packet.Message);
 }
예제 #20
0
 public async Task Handle(IPacketContext context)
 {
     await this.Process(context.Serialiser.Deserialise <T>(context.PacketBytes), context);
 }
예제 #21
0
 public override async Task Process(ChatPacket packet, IPacketContext packetContext)
 {
     _logger.LogDebug("Client received the response packet: " + packet.Message);
 }
예제 #22
0
 public override async Task Process(PingPacket packet, IPacketContext context)
 {
     this.logger.LogDebug("Received a ping packet from " + context.Sender.EndPoint);
 }
예제 #23
0
 public override async Task Process(TestPacketThing packet, IPacketContext context)
 {
 }