File LUBE.lua
Set the seperators This allows the user to nest tables, as the seperators won't conflict
Functions
lube.bin:pack (t) | Pack a table Does what you'd expect |
lube.bin:packvalue (i, v) | Pack a single value Internal, do not use |
lube.bin:setseperators (null, one) | Set the seperators This allows the user to nest tables, as the seperators won't conflict |
lube.bin:unpack (s) | Unpack a string Does the opposite of pack, table -> string |
lube.bin:unpackvalue (s) | Unpack a single value Internal, do not use |
lube.client (...) | Creates a client object |
lube.client:Init (socktype) | Initialize the client Automatically called when creating a connection object |
lube.client:connect (host, port, dns) | Connect to a server |
lube.client:disableBroadcast () | Disable connecting to the broadcast address (warning: has direct effect, old connection terminated unclean) |
lube.client:disconnect () | Disconnect from the server |
lube.client:doPing (dt) | Do a ping (according to settings) Does a ping whenever needed |
lube.client:enableBroadcast () | Enable connecting to the broadcast address |
lube.client:receive () | Receive data from the server |
lube.client:send (data) | Send data to the server |
lube.client:setCallback (cb) | Set callback |
lube.client:setHandshake (hshake) | Set handshake Handshake is a string to identify the opening and closing of the connection |
lube.client:setPing (enabled, time, msg) | Set ping Set the options for the ping |
lube.client:update (dt) | Search for new messages and call the appropriate callback Also does ping, since 0.6 |
lube.easy.generateKey (keylength) | Internal: Generate a key for 'secured' connections |
lube.easy:client (host, port, table, serializer, deserializer, rate, object) | Start a client |
lube.easy:gettable () | Internal: Get the converted table |
lube.easy:server (port, table, serializer, deserializer, rate, object, keylength) | Start a server |
lube.easy:settable (data) | Internal: Set the converted table |
lube.easy:update (dt) | Update (runs a synchronization cycle when necessary) |
lube.server (...) | Creates a server object |
lube.server.tcp:acceptAll () | Accepts connecting clients (TCP only) |
lube.server:Init (port, socktype) | Initializes the server |
lube.server:checkPing (dt) | Check for ping messages If clients are timed out, disconnect them |
lube.server:receive () | Receive data from clients |
lube.server:respondToServBrowser (active, info) | Sets if the server should respond to Server Browser requests |
lube.server:send (data, rcpt) | Send data to clients |
lube.server:setCallback (recv, connect, disconnect) | Sets the callbacks |
lube.server:setHandshake (hshake) | Sets a handshake |
lube.server:setPing (enabled, time, msg) | Set ping |
lube.server:startserver (port) | Start the server Sets the server, is normally called by init |
lube.server:update (dt) | Update the server Checks for incoming messages, and classifies as ping, connect, disconnect and raw data Also checks ping (since 0.6) |
Functions
- lube.bin:pack (t)
-
Pack a table Does what you'd expect
Parameters
- t: Table to pack
- lube.bin:packvalue (i, v)
-
Pack a single value Internal, do not use
Parameters
- i:
- v:
See also:
- lube.bin:setseperators (null, one)
-
Set the seperators This allows the user to nest tables, as the seperators won't conflict
Parameters
- null: The first seperator character, if empty set to default
- one: The second seperator character, if empty set to default
- lube.bin:unpack (s)
-
Unpack a string Does the opposite of pack, table -> string
Parameters
- s: The string, which is generally a result of lub.bin:pack
- lube.bin:unpackvalue (s)
-
Unpack a single value Internal, do not use
Parameters
- s:
See also:
- lube.client (...)
-
Creates a client object
Parameters
- ...: What to pass to Init
See also:
- lube.client:Init (socktype)
-
Initialize the client Automatically called when creating a connection object
Parameters
- socktype: Type of socket, tcp/udp/user-created, udp is default
- lube.client:connect (host, port, dns)
-
Connect to a server
Parameters
- host:
- port:
- dns: Specify if the host is a name or an IP, if it's a hostname it should do a DNS lookup
- lube.client:disableBroadcast ()
- Disable connecting to the broadcast address (warning: has direct effect, old connection terminated unclean)
- lube.client:disconnect ()
- Disconnect from the server
- lube.client:doPing (dt)
-
Do a ping (according to settings) Does a ping whenever needed
Parameters
- dt: Delta time, as passed to update
See also:
- lube.client:enableBroadcast ()
- Enable connecting to the broadcast address
- lube.client:receive ()
- Receive data from the server
- lube.client:send (data)
-
Send data to the server
Parameters
- data:
- lube.client:setCallback (cb)
-
Set callback
Parameters
- cb: A callback called on an incoming message
See also:
- lube.client:setHandshake (hshake)
-
Set handshake Handshake is a string to identify the opening and closing of the connection
Parameters
- hshake: A handshake, shared by server and client
- lube.client:setPing (enabled, time, msg)
-
Set ping Set the options for the ping
Parameters
- enabled: Is enabled (true/false)
- time: How many seconds between pings?
- msg: What is the ping package content (should be same between server and client, filtered)
See also:
- lube.client:update (dt)
-
Search for new messages and call the appropriate callback Also does ping, since 0.6
Parameters
- dt: Delta-time, since 0.6
See also:
- lube.easy.generateKey (keylength)
-
Internal: Generate a key for 'secured' connections
Parameters
- keylength:
- lube.easy:client (host, port, table, serializer, deserializer, rate, object)
-
Start a client
Parameters
- host:
- port:
- table:
- serializer:
- deserializer:
- rate:
- object:
See also:
- lube.easy:gettable ()
- Internal: Get the converted table
- lube.easy:server (port, table, serializer, deserializer, rate, object, keylength)
-
Start a server
Parameters
- port:
- table: Table to be synchronized
- serializer: Serializer used to turn the table into strings
- deserializer: Deserializer used to turn strings into tables
- rate: Speed at which it's synchronized
- object: Connection object
- keylength: Optional: Length of the key
- lube.easy:settable (data)
-
Internal: Set the converted table
Parameters
- data:
- lube.easy:update (dt)
-
Update (runs a synchronization cycle when necessary)
Parameters
- dt:
- lube.server (...)
-
Creates a server object
Parameters
- ...: What to pass to Init
See also:
- lube.server.tcp:acceptAll ()
- Accepts connecting clients (TCP only)
- lube.server:Init (port, socktype)
-
Initializes the server
Parameters
- port: Which port to listen on
- socktype: Type of socket, can be udp/tcp/user-created, default is udp
- lube.server:checkPing (dt)
-
Check for ping messages If clients are timed out, disconnect them
Parameters
- dt: Delta-time as passed to update
- lube.server:receive ()
- Receive data from clients
- lube.server:respondToServBrowser (active, info)
-
Sets if the server should respond to Server Browser requests
Parameters
- active: Should the server respond
- info: A table containing the server name and version as named keys
- lube.server:send (data, rcpt)
-
Send data to clients
Parameters
- data:
- rcpt: Recipient, if nil then sends to all clients
- lube.server:setCallback (recv, connect, disconnect)
-
Sets the callbacks
Parameters
- recv: Callback called on incoming data (filtered): function(data, id)
- connect: Callback called when client connects: function(id)
- disconnect: Callback called when client disconnects (also called by ping): function(id)
- lube.server:setHandshake (hshake)
-
Sets a handshake
Parameters
- hshake: A unqiue string, shared by client and server to identify connecting and disconnecting users
See also:
- lube.server:setPing (enabled, time, msg)
-
Set ping
Parameters
- enabled:
- time:
- msg:
See also:
- lube.server:startserver (port)
-
Start the server Sets the server, is normally called by init
Parameters
- port:
See also:
- lube.server:update (dt)
-
Update the server Checks for incoming messages, and classifies as ping, connect, disconnect and raw data Also checks ping (since 0.6)
Parameters
- dt: Delta-time