Child pages
  • udp

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Rev: 1381948887907

...

HTML Table
id
classservoy sSummary
Colgroup Tag
Column
padding0px
width80px

Column

Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Method Summary
Table Body (tbody)
Table Row (tr)
Table Cell (td)
JSPacket
Table Cell (td)
#createNewPacketcreateNewPacket()
Create a new empty packet.
tbody
Table Body (tbody)
Table Row (tr)
Table Cell (td)
JSPacket
Table Cell (td)
#getReceivedPacketgetReceivedPacket()
Get a packet from receive buffer, read buffer until empty (null is returned).
tbody
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
#sendPacketsendPacket(destIpOrHostname, packet)
Send a packet.
tbody
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
#sendPacketsendPacket(destIpOrHostname, packet, port)
Send a packet on another port.
tbody
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
#startSocketstartSocket(port_number, method_to_call_when_packet_received_and_buffer_is_empty)
Start a UDP socket for a port.
Table Row (tr)
Table Cell (td)
void
Table Cell (td)
#stopSocketstopSocket()
Stop the UDP socket for a port.
Table Body (tbody)
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
#testPackettestPacket(packet)
Put a test packet in the receive buffer to test your method call and getReceivedPacket.

HTML Table
idfunction
classservoy sDetail
Colgroup Tag
Column
padding0px
width100%

Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan1
Method Details
Table Body (tbody)
idcreateNewPacket
Table Row (tr)
idname
Table Cell (td)
createNewPacket
Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
JSPacket
Span
stylefont-weight: bold;
createNewPacket
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Create a new empty packet.
Table Row (tr)
idret
Table Cell (td)
Returns
Div
classsIndent
JSPacket
Table Row (tr)
idsam
Table Cell (td)
Sample
Div
classsIndent
Code Block
languagejavascript

...

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

...

Table Row (tr)
classlastDetailRow
Table Cell (td)

Table Body (tbody)
idgetReceivedPacket
Table Row (tr)
idname
Table Cell (td)
getReceivedPacket
Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
JSPacket
Span
stylefont-weight: bold;
getReceivedPacket
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Get a packet from receive buffer, read buffer until empty (null is returned).
Table Row (tr)
idret
Table Cell (td)
Returns
Div
classsIndent
JSPacket
Table Row (tr)
idsam
Table Cell (td)
Sample
Div
classsIndent
Code Block
languagejavascript

...

var packet = null
while( ( packet = plugins.udp.getReceivedPacket() ) != null)
{
	var text = packet.readUTF()
	var count = packet.readInt()
}

...

Table Row (tr)
classlastDetailRow
Table Cell (td)

Table Body (tbody)
idsendPacket-String_JSPacket
Table Row (tr)
idname
Table Cell (td)
sendPacket
Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
sendPacket
Span
(destIpOrHostname, packet)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Send a packet.
Table Row (tr)
idprs
Table Cell (td)
Parameters
Div
classsIndent
{String} destIpOrHostname

...

- the ip of the destination or the hostname
{JSPacket} packet

...

- the JSPacket to send
Table Row (tr)
idret
Table Cell (td)
Returns
Div
classsIndent
Boolean
Table Row (tr)
idsam
Table Cell (td)
Sample
Div
classsIndent
Code Block
languagejavascript

...

var packet = plugins.udp.createNewPacket()
packet.writeUTF('hello world!')
plugins.udp.sendPacket('10.0.0.1',packet)

...

Table Row (tr)
classlastDetailRow
Table Cell (td)

Table Body (tbody)
idsendPacket-String_JSPacket_Number
Table Row (tr)
idname
Table Cell (td)
sendPacket
Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
sendPacket
Span
(destIpOrHostname, packet, port)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Send a packet on another port.
Table Row (tr)
idprs
Table Cell (td)
Parameters
Div
classsIndent
{String} destIpOrHostname

...

- the ip of the destination or the hostname
{JSPacket} packet

...

- the JSPacket to send
{Number} port

...

- the port on which to send the packet
Table Row (tr)
idret
Table Cell (td)
Returns
Div
classsIndent
Boolean
Table Row (tr)
idsam
Table Cell (td)
Sample
Div
classsIndent
Code Block
languagejavascript

...

var packet = plugins.udp.createNewPacket()
packet.writeUTF('hello world!')
plugins.udp.sendPacket('10.0.0.1',packet, 4321)

...

Table Row (tr)
classlastDetailRow
Table Cell (td)

Table Body (tbody)
idstartSocket-Number_Object
Table Row (tr)
idname
Table Cell (td)
startSocket
Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
startSocket
Span
(port_number, method_to_call_when_packet_received_and_buffer_is_empty)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Start a UDP socket for a port.
Table Row (tr)
idprs
Table Cell (td)
Parameters
Div
classsIndent
{Number} port_number

...

- the local port that this UDP socket will bind to.
{Object} method_to_call_when_packet_received_and_buffer_is_empty

...

- when the socket receives one or more packages, it calls this method once.
The method will no longer be called even if new packages are received - until a call to UDPProvider#js_getReceivedPacket() returns null. So you should
consume all available packets before you expect this method to be called again.
Table Row (tr)
idret
Table Cell (td)
Returns
Div
classsIndent
Boolean
Table Row (tr)
idsam
Table Cell (td)
Sample
Div
classsIndent
Code Block
languagejavascript

...

plugins.udp.startSocket(1234,my_packet_process_method)

...

Table Row (tr)
classlastDetailRow
Table Cell (td)

Table Body (tbody)
idstopSocket
Table Row (tr)
idname
Table Cell (td)
stopSocket
Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
void
Span
stylefont-weight: bold;
stopSocket
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Stop the UDP socket for a port.
Table Row (tr)
idret
Table Cell (td)
Returns
Div
classsIndent
void
Table Row (tr)
idsam
Table Cell (td)
Sample
Div
classsIndent
Code Block
languagejavascript

...

plugins.udp.stopSocket()

...

Table Row (tr)
classlastDetailRow
Table Cell (td)

Table Body (tbody)
idtestPacket-JSPacket
Table Row (tr)
idname
Table Cell (td)
testPacket
Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
testPacket
Span
(packet)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Put a test packet in the receive buffer to test your method call and getReceivedPacket.
Table Row (tr)
idprs
Table Cell (td)
Parameters
Div
classsIndent
{JSPacket} packet
Table Row (tr)
idret
Table Cell (td)
Returns
Div
classsIndent
Boolean
Table Row (tr)
idsam
Table Cell (td)
Sample
Div
classsIndent
Code Block
languagejavascript

...

var packet = plugins.udp.createNewPacket()
packet.writeUTF('hello world!')
plugins.udp.testPacket(packet)

...

Table Row (tr)
classlastDetailRow
Table Cell (td)