LitDev Extension API
LDClient
Server and Client communication between computers.
Separate programs are required for the server and client - this is for the client.
CheckServer | CloseDelay | Connect |
Disconnect | Disconnected | GetClients |
LastServerMessage | Name | SendMessage |
ServerMessage | UpdateDynamic | UpdateStatic |
CheckServer(server)
Test if a server is available for connection.
Do not call this method at a high frequency (> 1 per second).
server The server connection ip:port (e.g. "192.168.1.60:100").
This value is returned by LDServer.Start.
returns "AVAILABLE" or "UNAVAILABLE"
CloseDelay
A delay in ms (default 100) when disconnecting to allow a message to be sent before connection closed (Disconnect).
This delay should also be set for the server in LDServer.CloseDelay.
Connect(server,auto)
Connect to a server.
server The server connection ip:port (e.g. "192.168.1.60:100").
This value is returned by LDServer.Start.
auto Enable auto message passing "True" or "False".
If this is used (recommended) then all client data is passed via server to all other clients,
and no processing of send and receive events is required.
The data is updated to arrays of data (indexed by client name) that is returned from the Update methods.
The auto option should be the same for server and all clients.
returns "SUCCESS", "FAILED" or "ALREADY_CONNECTED"
Disconnect()
Disconnect the client from the server.
returns "SUCCESS", "FAILED" or "NOT_CONNECTED"
Disconnected
Event when server disconnects this client.
GetClients()
Get a list of current connected clients.
returns An array of current client names or "" for none.
LastServerMessage
The last server message.
Name
This client's name.
Get or set your name.
SendMessage(message)
Send a message to the server.
message The message may be any variable including an array.
returns "SUCCESS", "FAILED" or "NOT_CONNECTED"
ServerMessage
Event when the server sends a message to this client.
UpdateDynamic(data)
Update client data when using the auto message passing.
This is for small quantities of frequently changing data, like sprite coordinates.
this method uses the last updated client data stored on the client and is therefore fast.
data The data for this client to propagate to other clients.
returns An array indexed by client names with current data for all existing clients.
UpdateStatic(data)
Update client data when using the auto message passing.
This is for larger quantities of infrequently changing data, like client configuration.
This method uses data stored and retrieved from the server so may be slower than UpdateDynamic since it waits for server retreived data,
guaranteeing that all client data is fully synced.
data The data for this client to propagate to other clients.
returns An array indexed by client names with current data for all existing clients.