local object = iNet.open( number channel, number replyChannel, string side )
Creates and returns an iNet object.
local tbl = { iNet.waitForAny( object iNet Object, ... ) }
Waits for any of the object to receive a message, and returns the message values.
local tbl = { iNet.waitForAll( object iNet Object, ... ) }
Waits for all objects to receive a message, and returns message values.
Object Functions (accessible through object:* )
object:send( string/table message )
Sends a message
local message, distance, sender = object:receive()
Receives messages. Sender is the computer label, if available, or the computer ID.
object:reply( message )
Sends a message to the computer that last communicated with the object.
object:repeat()
Repeater program. Duh.
object:setProctal( string proctal )
Sets the proctal filter. This will automatically be applied to send and receive. In 1.2, the spelling was updated to object:setProtocol
object:setEncryption( function encrypt )
An advanced setting for encrypting messages. The function specified will be given string message. Automatically encrypts object:send.
object:setDecryption( function decrypt )
The counterpart to object:setEncryption. This will automatically decrypt received messages.
object:removeEncryption()
Removes the encryption filter (if any)
object:removeDecryption()
Removes the decryption filter (if any)
object:sendFile( string fileName )
Sends a file. Be aware that some files may be corrupted when sent through the event filter. object:receive() will recognise it as a file and save it as the filename specified. If this overwrites something you had, well too bad for you. It will also return the filename, instead of the fileData. In 1.2, this should no longer be a concern, because all data is sent with base64 encoding
Downloads:
1.0 - pastebin get FWpbap6B
1.2 (beta) - pastebin get vuzF5t8p
--#sending script (run this SECOND) os.loadAPI( "iNet" ) local channel = iNet.open( 255, 256, "top" ) channel:setProctal( "Examples" ) --#note: in 1.2, this was changed to channel:setProtocol( "Examples" ) channel:send( "Hello" ) local message, distance, sender = channel:receive() print( "Recieved '" .. message .. "' from " .. sender .. ", " .. distance .. "m away" ) channel:reply( "Confirm" ) --#receiving script (run this FIRST) os.loadAPI( "iNet" ) local channel = iNet.open( 23, 255, "top" ) channel:setProctal( "Examples" ) --#see above note regarding this function and 1.2 local message, distance, sender = channel:receive() print( "Recieved '" .. message .. "' from " .. sender .. ", " .. distance .. "m away" ) channel:send( "This will be ignored as it is on the wrong channel!" ) channel:reply( "Hello, " .. sender ) local message, distance, sender = channel:receive() print( "Recieved '" .. message .. "' from " .. sender .. ", " .. distance .. "m away" )
Edited by KingofGamesYami, 21 August 2014 - 03:12 AM.