fix byte[] packets

This commit is contained in:
Bluzume 2021-11-02 02:41:23 -04:00
parent a7ebf7ad0c
commit 1653944b51
2 changed files with 11 additions and 10 deletions

View file

@ -98,9 +98,12 @@ namespace HISP.Server
// HI1 Packets are terminates by 0x00 so we have to read until we receive that terminator // HI1 Packets are terminates by 0x00 so we have to read until we receive that terminator
if (!ClientSocket.Connected) if (!ClientSocket.Connected)
isDisconnecting = true; Disconnect();
if(e.SocketError != SocketError.Success)
Disconnect();
if (e.SocketError == SocketError.Success && !isDisconnecting) if (!isDisconnecting)
{ {
int availble = e.BytesTransferred; int availble = e.BytesTransferred;
@ -123,8 +126,6 @@ namespace HISP.Server
return; return;
} }
Disconnect();
// Stop Timers // Stop Timers
if (inactivityTimer != null) if (inactivityTimer != null)
inactivityTimer.Dispose(); inactivityTimer.Dispose();

View file

@ -341,7 +341,7 @@ namespace HISP.Server
packet[0] = PACKET_SWFMODULE; packet[0] = PACKET_SWFMODULE;
Array.Copy(drawingBytes, 0, packet, 1, drawingBytes.Length); Array.Copy(drawingBytes, 0, packet, 1, drawingBytes.Length);
packet[packet.Length] = PACKET_TERMINATOR; packet[packet.Length-1] = PACKET_TERMINATOR;
return packet; return packet;
} }
@ -361,7 +361,7 @@ namespace HISP.Server
Array.Copy(infoBytes, 0, packet, 2, infoBytes.Length); Array.Copy(infoBytes, 0, packet, 2, infoBytes.Length);
packet[packet.Length] = PACKET_TERMINATOR; packet[packet.Length-1] = PACKET_TERMINATOR;
return packet; return packet;
} }
@ -446,7 +446,7 @@ namespace HISP.Server
Array.Copy(userBytes, 0, packet, 9, userBytes.Length); Array.Copy(userBytes, 0, packet, 9, userBytes.Length);
packet[packet.Length] = PACKET_TERMINATOR; packet[packet.Length-1] = PACKET_TERMINATOR;
return packet; return packet;
} }
@ -466,7 +466,7 @@ namespace HISP.Server
Array.Copy(loginFailMessage, 0, packet, 2, loginFailMessage.Length); Array.Copy(loginFailMessage, 0, packet, 2, loginFailMessage.Length);
packet[packet.Length] = PACKET_TERMINATOR; packet[packet.Length-1] = PACKET_TERMINATOR;
return packet; return packet;
} }
@ -478,7 +478,7 @@ namespace HISP.Server
packet[0] = PACKET_PLAYER; packet[0] = PACKET_PLAYER;
Array.Copy(profileBytes, 0, packet, 1, profileBytes.Length); Array.Copy(profileBytes, 0, packet, 1, profileBytes.Length);
packet[packet.Length] = PACKET_TERMINATOR; packet[packet.Length-1] = PACKET_TERMINATOR;
return packet; return packet;
} }
@ -503,7 +503,7 @@ namespace HISP.Server
packet[8] = (byte)(direction + 20); packet[8] = (byte)(direction + 20);
packet[9] = (byte)(Convert.ToInt32(walk) + 20); packet[9] = (byte)(Convert.ToInt32(walk) + 20);
packet[packet.Length] = PACKET_TERMINATOR; packet[packet.Length-1] = PACKET_TERMINATOR;
return packet; return packet;
} }