mirror of
https://github.com/islehorse/HISP.git
synced 2025-07-05 06:42:46 +12:00
Add Multiple transports system, begin work on WebSockets
This commit is contained in:
parent
e869a23463
commit
e74f66a439
22 changed files with 3752 additions and 3301 deletions
38
HorseIsleServer/LibHISP/Server/Network/XmlSocket.cs
Normal file
38
HorseIsleServer/LibHISP/Server/Network/XmlSocket.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
using HISP.Security;
|
||||
using HISP.Util;
|
||||
using System.Text;
|
||||
|
||||
namespace HISP.Server.Network
|
||||
{
|
||||
public class XmlSocket : Transport
|
||||
{
|
||||
public override void ProcessReceivedPackets(int available, byte[] buffer)
|
||||
{
|
||||
// In XmlSocket Packets are terminates by 0x00 so we have to read until we receive that terminator
|
||||
for (int i = 0; i < available; i++)
|
||||
{
|
||||
currentPacket.Add(buffer[i]);
|
||||
if (buffer[i] == PacketBuilder.PACKET_TERMINATOR) // Read until \0...
|
||||
{
|
||||
onReceiveCallback(currentPacket.ToArray());
|
||||
currentPacket.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
// Handle XMLSocket Policy File
|
||||
if (Helper.ByteArrayStartsWith(buffer, Encoding.UTF8.GetBytes("<policy-file-request/>")))
|
||||
{
|
||||
this.Send(CrossDomainPolicy.GetPolicyFile());
|
||||
}
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "XmlSocket";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue