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
                }
            }
        }
Exemple #2
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);
            }
        }
        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);
                }
            }
        }
        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
            }
        }
Exemple #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
                }
            }
        }
        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);
            }
        }
Exemple #7
0
        private void ServerDataReceived(NetworkPacket packet)
        {
            var format = NetworkFormatManager.GetServerFormat(packet.Command);

            if (format != null)
            {
                try
                {
                    Read(packet, format);
                    if (_handlers[format.Command] != null)
                    {
                        _handlers[format.Command].Invoke(this,
                                                         new object[]
                        {
                            format
                        });
                    }
                }
                catch (Exception)
                {
                    //ignore
                }
            }
        }