Показать сообщение отдельно
Непрочитано 15.05.2016, 00:41   #9
Забанен за кидаловo/обман/развод

Автор темы (Топик Стартер) Re: Ошибка сервера

Цитата:
Сообщение от Awiion Посмотреть сообщение
Тебе единственное что надо была сделать поставить тру\катч в BeginRead
Код:
                
public void BeginRead(IAsyncResult asyncResult)
                {
                    try
                    {
                        int received = Stream.EndRead(asyncResult);
                        Log.Info("Received = {0}", received);
                        while (received >= 6)
                        {
                            int length = BitConverter.ToUInt16(buffer, 0) & 0x7FFF;

                            byte[] temp = new byte[length + 2];
                            Array.Copy(buffer, 2, temp, 0, temp.Length);
                            int bits = Id % 7 + 1;
                            BitShift.Unshift(temp, bits);
                            byte[] opcode = new byte[] { temp[0], temp[1] };
                            RecvOpcode packet = (RecvOpcode)BitConverter.ToUInt16(opcode, 0);
                            Type t = Type.GetType("PiercingBlow.Login.Network.Recv." + packet.ToString());
                            Log.Info("PacketId = {0} Lenght = {1}", BitConverter.ToUInt16(opcode, 0), temp.Length);
                            if (t != null)
                            {
                                ClientPacket clientpacket = (ClientPacket)Activator.CreateInstance(t);
                                clientpacket.Client = this;
                                clientpacket.Process(buffer);
                            }
                            else
                            {
                                Log.Trace(temp.ToHex());
                            }
                            received -= length + 4;
                            Array.Copy(buffer, length + 4, buffer, 0, received);
                        }
                        Stream.BeginRead(buffer, 0, buffer.Length, BeginRead, null);
                    }
                    catch (IOException)
                    {
                        Disconnected();
                    }
                    catch (Exception ex)
                    {
                        Disconnected();
                        Log.Error("error",ex);
                    }
                    }
Boris2105 вне форума Ответить с цитированием