PROGRAMMATOR Написал:[Error] Disconnect - этого мало чтобы понять, что случилось.
[SRC="csharp"]
public void BeginRead(IAsyncResult asyncResult)
{
try
{
int received = Stream.EndRead(asyncResult);
if (received != 0)
{
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());
if (t != null)
{
ClientPacket clientpacket = (ClientPacket)Activator.CreateInstance(t);
clientpacket.Client = this;
clientpacket.Process(temp);
}
else
{
Log.Info("PacketId = {0}", BitConverter.ToUInt16(opcode, 0), buffer.Length);
Log.Trace(temp.ToHex());
}
received -= length + 4;
Array.Copy(buffer, length + 4, buffer, 0, received); // << Копируем оставшиеся данные в начало буфера
}
Stream.BeginRead(buffer, 0, buffer.Length, BeginRead, Stream);
}
else
{
OnDisconnected(this);
}
}
catch (IOException)
{
OnDisconnected(this);
}
catch (Exception ex)
{
OnDisconnected(this);
Log.Error("Disconnect",ex);
}
}
[/SRC]
[SRC="csharp"]
WriteB(new byte[15]);
string id = account.Id.ToString();
WriteC(0);
WriteS(id, id.Length);
WriteC(0);
WriteC(account.Login.Length);
WriteS(account.Login);
WriteQ(account.Id);
WriteD((int)state);
[/SRC]