{div:style=display:none} DO NOT EDIT THE CONTENT OF THIS PAGE DIRECTLY (EXCEPT INSIDE THE DIV BELOW WITH ID=DESCRIPTION), UNLESS YOU KNOW WHAT YOU'RE DOING. THE STRUCTURE OF THE CONTENT IS VITAL IN BEING ABLE TO AUTO UPDATE THE CONTENT THROUGH THE DOC GENERATOR{div} {div:id=description}{div}\\ {table:id=|class=servoy sReturnTypes}{tr:style=height: 30px;}{th}Return Types{th}{tr}{tr}{td}{span:class=sWordList}[JSPacket]{span}{td}{tr}{table}\\ {table:id=|class=servoy sSummary}{colgroup}{column:width=80px|padding=0px}{column}{column}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=2}Method Summary{th}{tr}{tbody}{tr}{td}[JSPacket]{td}{td}[#createNewPacket]\() Create a new empty packet.{td}{tr}{tbody}{tbody}{tr}{td}[JSPacket]{td}{td}[#getReceivedPacket]\() Get a packet from receive buffer, read buffer until empty (null is returned).{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#sendPacket]\(destIpOrHostname, packet) Send a packet.{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#sendPacket]\(destIpOrHostname, packet, port) Send a packet on another port.{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#startSocket]\(port_number, method_to_call_when_packet_received_and_buffer_is_empty) Start a UDP socket for a port.{td}{tr}{tbody}{tbody}{tr}{td}void{td}{td}[#stopSocket]\() Stop the UDP socket for a port.{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#testPacket]\(packet) Put a test packet in the receive buffer to test your method call and getReceivedPacket.{td}{tr}{tbody}{table}\\ {table:id=function|class=servoy sDetail}{colgroup}{column:width=100%|padding=0px}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=1}Method Details{th}{tr}{tbody:id=createNewPacket}{tr:id=name}{td}h6.createNewPacket{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[JSPacket]{span}{span:style=font-weight: bold;}createNewPacket{span}{span}\(){span}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[JSPacket]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript} 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 {code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=getReceivedPacket}{tr:id=name}{td}h6.getReceivedPacket{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[JSPacket]{span}{span:style=font-weight: bold;}getReceivedPacket{span}{span}\(){span}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[JSPacket]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript} var packet = null while( ( packet = plugins.udp.getReceivedPacket() ) != null) { var text = packet.readUTF() var count = packet.readInt() } {code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=sendPacket-String_JSPacket}{tr:id=name}{td}h6.sendPacket{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[Boolean]{span}{span:style=font-weight: bold;}sendPacket{span}{span}\(destIpOrHostname, packet){span}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[String]} destIpOrHostname -- the ip of the destination or the hostname \{[JSPacket]} packet -- the JSPacket to send {div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Boolean]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript} var packet = plugins.udp.createNewPacket() packet.writeUTF('hello world!') plugins.udp.sendPacket('10.0.0.1',packet) {code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=sendPacket-String_JSPacket_Number}{tr:id=name}{td}h6.sendPacket{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[Boolean]{span}{span:style=font-weight: bold;}sendPacket{span}{span}\(destIpOrHostname, packet, port){span}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[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 {div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Boolean]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript} var packet = plugins.udp.createNewPacket() packet.writeUTF('hello world!') plugins.udp.sendPacket('10.0.0.1',packet, 4321) {code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=startSocket-Number_Object}{tr:id=name}{td}h6.startSocket{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[Boolean]{span}{span:style=font-weight: bold;}startSocket{span}{span}\(port_number, method_to_call_when_packet_received_and_buffer_is_empty){span}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[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. {div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Boolean]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript} plugins.udp.startSocket(1234,my_packet_process_method) {code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=stopSocket}{tr:id=name}{td}h6.stopSocket{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}void{span}{span:style=font-weight: bold;}stopSocket{span}{span}\(){span}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}void{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript} plugins.udp.stopSocket() {code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=testPacket-JSPacket}{tr:id=name}{td}h6.testPacket{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[Boolean]{span}{span:style=font-weight: bold;}testPacket{span}{span}\(packet){span}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[JSPacket]} packet {div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Boolean]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript} var packet = plugins.udp.createNewPacket() packet.writeUTF('hello world!') plugins.udp.testPacket(packet) {code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{table} |