![]() |
Murl Engine Lua Addon API
Version 1.0 beta
|
The socket client thread interface.
The socket client implements a thread for network communication which can be commanded by a logic implementation.
The client can connect to an ISocketServer either via listening for broadcasts or by specifying an address directly.
If the client is connected to a server, data can be transfered from an to the server simultaneously via the network.
Get the name of the client.
String GetClientName()
Get the unique identifier of the client.
String GetUniqueIdentifier()
Start listening for broadcasts from an ISocketServer.
Boolean StartListenBroadcast(Murl.SharedPointer.NetISocketAddressConst address)
address | The address to bind for listening. |
Stop listening for broadcasts from an ISocketServer. Stop listening for broadcasts clears the broadcast packet queue.
Boolean StopListenBroadcast()
Check if the thread is listening for braodcasts.
Boolean IsListenBroadcast()
Get the maximum number of broadcast packets the thread can store. The default broadcast packets queue length is 10.
Integer GetMaxBroadcastQueueLength()
Set the maximum number of broadcast packet the thread can store. If the given maximum length is smaller than the current maximum length, the broadcast packet queue is cleared. If the broadcast packet queue is full, the oldest packet is discarded.
SetMaxBroadcastQueueLength(Integer maxLength)
maxLength | The maximum number of broadcast packets the thread can store. |
Clear the incoming boradcast packets queue.
ClearBroadcastQueue()
Get a broadcast packet from a server. If the packet returned is not null, the logic can decide depending on the packet information if the client should accept or deny the server. The logic must call AcceptServer() or DenyServer() to remove the packet from the broadcast queue.
Murl.SharedPointer.NetISocketPacketConst GetServerBroadcast()
Accept a server connection. When connecting to the server was successful, listening for broadcasts is stopped and the broadcast packet queue is cleared.
Boolean AcceptServer(Murl.SharedPointer.NetISocketPacketConst serverBroadcast)
serverBroadcast | The broadcast packet received by GetServerBroadcast(). |
Deny a server broadcast packet.
Boolean DenyServer(Murl.SharedPointer.NetISocketPacketConst serverBroadcast)
serverBroadcast | The broadcast packet received by GetServerBroadcast(). |
Connect to a server using an address directly. The parameters name and unique identifier of the server must not be the real server information, these values are simply stored in the received packets to help identifying the sender. When connecting to the server was successful, listening for broadcasts is stopped and the broadcast packet queue is cleared.
Boolean ConnectToServer(Murl.SharedPointer.NetISocketAddressConst address, String name, String uniqueId)
address | The server address to connect to. |
name | The name of the server. |
uniqueId | The unique identifier of the server. |
Disconnect from the server.
Boolean DisconnectServer()
Check if the client is connected to a server or connecting to the server is in progress.
Boolean IsConnectedOrConnecting()
Check if the client is connected to a server.
Boolean IsConnected()
Get detailed information of a connected server.
Murl.SharedPointer.NetISocketPacket GetServerInfo()
Send data to the server.
Boolean Send(Murl.ConstData data)
data | The data object to send. |
Get the maximum number of received packets the thread can store. The default received packets queue length is 20.
Integer GetMaxReceiveQueueLength()
Set the maximum number of received packet the thread can store. Setting the maximum length clears the received packet queue. 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 server. 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.