コード例 #1
0
        public virtual void ClientDataReceived(TClient client, NetworkPacket packet)
        {
            var format = NetworkFormatManager.GetClientFormat(packet.Command);

            if (format == null)
            {
                return;
            }

            try
            {
                client.Read(packet, format);

                if (_handlers[format.Command] != null)
                {
                    _handlers[format.Command].Invoke(this,
                                                     new object[]
                    {
                        client,
                        format
                    });
                }
            }
            catch (Exception e)
            {
                ServerContext.Error(e);
            }
        }
コード例 #2
0
        public virtual void ClientDataReceived(TClient client, NetworkPacket packet)
        {
            var format = NetworkFormatManager.GetClientFormat(packet.Command);

            if (format != null)
            {
                try
                {
                    client.Read(packet, format);

                    if (_handlers[format.Command] != null)
                    {
                        _handlers[format.Command].Invoke(this,
                                                         new object[]
                        {
                            client,
                            format
                        });
                    }
                }
                catch (Exception)
                {
                    //ignore
                }
            }
        }
コード例 #3
0
        public void ProcessFormat(TClient client, NetworkPacket packet)
        {
            var format = NetworkFormatManager.GetClientFormat(packet.Command);

            if (format != null)
            {
                try
                {
                    client.Read(packet, format);

                    if (_handlers[format.Command] != null)
                    {
                        _handlers[format.Command].Invoke(this,
                                                         new object[]
                        {
                            client,
                            format
                        });
                    }
                }
                catch (Exception)
                {
                    //ignore
                }
            }
            else
            {
                if (ServerContext.Config.DebugMode)
                {
                    Console.WriteLine("Unhandled Client Format: 0x{0}", packet.Command);
                }
            }
        }
コード例 #4
0
        public virtual void ClientDataReceived(TClient client, NetworkPacket packet)
        {
            if (client == null)
            {
                return;
            }

            if (!client.ServerSocket.Connected)
            {
                return;
            }

            if (packet == null)
            {
                return;
            }

            NetworkFormat format;

            if (_formatCache.Exists(packet.Command))
            {
                format = _formatCache.Get(packet.Command);
            }
            else
            {
                format = NetworkFormatManager.GetClientFormat(packet.Command);
                _formatCache.AddOrUpdate(packet.Command, format, Timeout.Infinite);
            }

            if (format == null)
            {
                return;
            }

            try
            {
                client.Read(packet, format);

                if (_handlers[format.Command]?.Invoke(this,
                                                      new object[]
                {
                    client,
                    format
                }) != null)
                {
                }
            }
            catch (Exception e)
            {
                ServerContext.Report(e);
                //Ignore
            }
        }
コード例 #5
0
        public virtual void ClientDataReceived(TClient client, NetworkPacket packet)
        {
            if (client == null)
            {
                return;
            }

            if (!client.WorkSocket.Connected)
            {
                return;
            }

            if (packet == null)
            {
                return;
            }

            NetworkFormat format;

            if (FormatCache.Exists(packet.Command))
            {
                format = FormatCache.Get(packet.Command);
            }
            else
            {
                format = NetworkFormatManager.GetClientFormat(packet.Command);
                FormatCache.AddOrUpdate(packet.Command, format, Timeout.Infinite);
            }

            if (format != null)
            {
                try
                {
                    client.Read(packet, format);

                    _handlers[format.Command]?.Invoke(this,
                                                      new object[]
                    {
                        client,
                        format
                    });
                }
                catch (Exception)
                {
                    //ignore
                }
            }
        }
コード例 #6
0
        public virtual void ClientDataReceived(TClient client, NetworkPacket packet)
        {
            var format = NetworkFormatManager.GetClientFormat(packet.Command);

            if (format == null)
            {
                return;
            }

            try
            {
                if (!Clients.Exists(i => i.Serial == client.Serial))
                {
                    return;
                }

                if (client.MapOpen && !(format is ClientFormat3F))
                {
                    return;
                }

                client.Read(packet, format);
                client.LastMessageFromClient = DateTime.UtcNow;

                if (_handlers[format.Command] != null)
                {
                    _handlers[format.Command].Invoke(this,
                                                     new object[]
                    {
                        client,
                        format
                    });
                }
            }
            catch (Exception e)
            {
                ServerContext.Error(e);
            }
        }