| RegisterPacket | ||
|---|---|---|
| Prototype | RegisterPacket( packetID, subCommand ) | |
| Purpose | ||
| Example of Usage |
function PacketRegistration()
{
RegisterPacket( 0x05, subCommand );
}
function onPacketReceive( socket, packetNum, subCommand )
{
switch( packetNum )
{
case 0x05: //Request Attack sent from client
{
//do stuff??
break;
}
default:
break;
}
}
| |
| ReserveSize | ||
|---|---|---|
| Prototype | bool ReserveSize( packetSize ) | |
| Purpose | ||
| Example of Usage | var myPacket = new Packet(); myPacket.ReserveSize( 7 ); //Reserve a size of 7 bytes for myPacket | |
| WriteByte | ||
|---|---|---|
| Prototype | bool WriteByte( position, value ) | |
| Purpose | ||
| Example of Usage | myPacket.WriteByte( 0, 0x73 ); //In byte-position 0 of myPacket, write the value 0x73 as a Byte | |
| WriteShort | ||
|---|---|---|
| Prototype | bool WriteShort( position, value ) | |
| Purpose | ||
| Example of Usage | myPacket.WriteShort( 1, 0x02 ); //in byte-position 1 of myPacket, write the value 0x02 as a Short | |
| WriteLong | ||
|---|---|---|
| Prototype | bool WriteLong( position, value ) | |
| Purpose | ||
| Example of Usage | myPacket.WriteLong( 3, mChar.serial ); //in byte-position 3 of myPacket, write the serial of mChar as a Long | |
| WriteString | ||
|---|---|---|
| Prototype | bool WriteString( position, string ) | |
| Purpose | ||
| Example of Usage | myPacket.WriteString( 7, "Text", 4 ); //In byte-position 7 of myPacket, write the specified text as a String, 4 bytes long | |
| Send | ||
|---|---|---|
| Prototype | bool Send( packet ) | |
| Purpose | Send the specified network-packet to a socket | |
| Example of Usage | pSock.Send( myPacket ); //send myPacket to pSock | |
| Free | ||
|---|---|---|
| Prototype | bool Free() | |
| Purpose | Free up the memory used for the packet? | |
| Example of Usage | myPacket.Free(); | |