![]() |
Murl Engine Lua Addon API
Version 1.0 beta
|
The socket server thread interface.
The socket server implements a thread for network communication which can be commanded by a logic implementation.
The server supports sending broadcasts for client connections and can hold connections to any number of ISocketClients.
If the server is connected to a client, data can be transfered from an to the client simultaneously via the network.
Get the name of the server.
String GetServerName()
Get the unique identifier of the server.
String GetUniqueIdentifier()
Start listening for incoming ISocketClient connections.
Boolean StartListen(Murl.SharedPointer.NetISocketAddressConst address)
address | The address to bind for listening. |
Stop listening for incomming ISocketClient connections.
Boolean StopListen()
Start sending broadcasts. Before starting broadcasts the listen address must be set by StartListen().
Boolean StartSendBroadcast(Murl.SharedPointer.NetISocketAddressConst address)
address | The address to send the broadcast. |
Stop sending broadcasts.
Boolean StopSendBroadcast()
Set the broacast clock time. The default clock time is 1 second. Every clockTime seconds one broadcast packet is sent.
SetBroadcastClock(Number clockTime)
clockTime | The broacast send clock time in seconds. |
Get the maximum number of accept packets the thread can store. The default accept packets queue length is 50.
Integer GetMaxAcceptQueueLength()
Set the maximum number of accept packet the thread can store. If the given maximum length is smaller than the current maximum length, the accept packet queue is cleared. If the accept packet queue is full, the client is denied.
SetMaxAcceptQueueLength(Integer maxLength)
maxLength | The maximum number of accept packets the thread can store. |
Clear the accept packets queue.
ClearAcceptQueue()
Get an accept packet from a client. If the packet returned is not null, the logic can decide depending on the packet information if the server should accept or deny the client. The logic must call AcceptClient() or DenyClient() to remove the packet from the accept queue.
Murl.SharedPointer.NetISocketPacketConst GetClientToAccept()
Accept a client connection.
Boolean AcceptClient(Murl.SharedPointer.NetISocketPacketConst clientToAccept)
clientToAccept | The accept packet received by GetClientToAccept(). |
Deny a client accept packet.
Boolean DenyClient(Murl.SharedPointer.NetISocketPacketConst clientToDeny)
clientToDeny | The accept packet received by GetClientToAccept(). |
Get the number of connected clients. The number of connected clients includes all accepted clients plus the number of clients waiting in the accept queue.
Integer GetNumberOfConnectedClients()
Check if the accepted clients list has changed.
Boolean, Murl.ChangeInspector HasAcceptedClientsChanged(Murl.ChangeInspector inspector)
inspector | The inspector to check. |
Get the unique identifiers of all accepted clients. Use HasAcceptedClientsChanged() to check for changes.
Murl.Array.String GetAcceptedClients(Murl.Array.String clientIds)
clientIds | The identifier string array return value. |
Get detailed information of a connected client. The GetAcceptedClients() method returns all accepted client identifiers.
Murl.SharedPointer.NetISocketPacket GetClientInfo(String clientId)
clientId | The unique identifier of the client. |
Disconnect a client. The GetAcceptedClients() method returns all accepted client identifiers.
Boolean Disconnect(String clientId)
clientId | The unique identifier of the client. |
Send data to a client. The GetAcceptedClients() method returns all accepted client identifiers.
Boolean Send(Murl.ConstData data, String clientId)
data | The data object to send. |
clientId | The unique identifier of the client. |
Get the maximum number of received packets the thread can store. The default received packets queue length is 50.
Integer GetMaxReceiveQueueLength()
Set the maximum number of received packet the thread can store. If the given maximum length is smaller than the current maximum length, the received packet queue is cleared. If the received packet queue is full, the oldest packet is discarded.
SetMaxReceiveQueueLength(Integer maxLength)
maxLength | The maximum number of received packets the thread can store. |
Clear the received packets queue.
ClearReceiveQueue()
Get a received packet from a client. The packet returned is removed from the received packets queue.
Murl.SharedPointer.NetISocketPacket GetReceivedData()
Converts the object content to a string in a reasonable format.