Skip to end of metadata
Go to start of metadata


Return Types
JSPacket

Method Summary
JSPacket #createNewPacket()
Create a new empty packet.
JSPacket #getReceivedPacket()
Get a packet from recieve buffer, read buffer until empty (null is returned).
Boolean #sendPacket(ip/host, packet, [port])
Send a packet.
Boolean #startSocket(portnumber, methodToInvokeWhenPacketReceivedAndBufferIsEmpty)
Start a UDP socket for a port.
void #stopSocket()
Stop the UDP socket for a port.
Boolean #testPacket(packet)
Put a test packet in the receive buffer to test your method call and getReceivedPacket.

Method Details
createNewPacket

JSPacket createNewPacket ()

Create a new empty packet.
Returns
JSPacket
Sample
var packet = plugins.udp.createNewPacket()
packet.writeUTF('hello world!')//writes UTF
packet.writeInt(12348293)//writes 4 bytes
packet.writeShort(14823)//writes 2 bytes
packet.writeByte(123)//writes 1 byte
getReceivedPacket

JSPacket getReceivedPacket ()

Get a packet from recieve buffer, read buffer until empty (null is returned).
Returns
JSPacket
Sample
var packet = null
while( ( packet = plugins.udp.getReceivedPacket() ) != null)
{
	var text = packet.readUTF()
	var count = packet.readInt()
}
sendPacket

Boolean sendPacket (ip/host, packet, [port])

Send a packet.
Parameters
ip/host
packet
[port]
Returns
Boolean
Sample
var packet = plugins.udp.createNewPacket()
packet.writeUTF('hello world!')
plugins.udp.sendPacket('10.0.0.1',packet)
startSocket

Boolean startSocket (portnumber, methodToInvokeWhenPacketReceivedAndBufferIsEmpty)

Start a UDP socket for a port.
Parameters
portnumber
methodToInvokeWhenPacketReceivedAndBufferIsEmpty
Returns
Boolean
Sample
plugins.udp.startSocket(1234,my_packet_process_method)
stopSocket

void stopSocket ()

Stop the UDP socket for a port.
Returns
void
Sample
plugins.udp.stopSocket()
testPacket

Boolean testPacket (packet)

Put a test packet in the receive buffer to test your method call and getReceivedPacket.
Parameters
packet
Returns
Boolean
Sample
var packet = plugins.udp.createNewPacket()
packet.writeUTF('hello world!')
plugins.udp.testPacket(packet)
  • No labels