Murl Engine Lua Addon API  Version 1.0 beta
Murl.Net.ISocketClient

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.


Table members

Methods


GetClientName()

Get the name of the client.

String GetClientName()

Returns
String The name of the client.

GetUniqueIdentifier()

Get the unique identifier of the client.

String GetUniqueIdentifier()

Returns
String The unique identifier of the client.

StartListenBroadcast(address)

Start listening for broadcasts from an ISocketServer.

Boolean StartListenBroadcast(Murl.SharedPointer.NetISocketAddressConst address)

Parameters
addressThe address to bind for listening.
Returns
Boolean true if passing the address was successful or the thread is already listening for broadcasts.

StopListenBroadcast()

Stop listening for broadcasts from an ISocketServer. Stop listening for broadcasts clears the broadcast packet queue.

Boolean StopListenBroadcast()

Returns
Boolean true if passing the command was successful or the thread is not listening for broadcasts.

IsListenBroadcast()

Check if the thread is listening for braodcasts.

Boolean IsListenBroadcast()

Returns
Boolean true if the thread is listening for braodcasts.

GetMaxBroadcastQueueLength()

Get the maximum number of broadcast packets the thread can store. The default broadcast packets queue length is 10.

Integer GetMaxBroadcastQueueLength()

Returns
Integer The maximum number of broadcast packets the thread can store.

SetMaxBroadcastQueueLength(maxLength)

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)

Parameters
maxLengthThe maximum number of broadcast packets the thread can store.

ClearBroadcastQueue()

Clear the incoming boradcast packets queue.

ClearBroadcastQueue()


GetServerBroadcast()

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()

Returns
Murl.SharedPointer.NetISocketPacketConst A broadcast packet from a server or null if the broadcast packet queue is empty.

AcceptServer(serverBroadcast)

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)

Parameters
serverBroadcastThe broadcast packet received by GetServerBroadcast().
Returns
Boolean true if accepting the server was successful.

DenyServer(serverBroadcast)

Deny a server broadcast packet.

Boolean DenyServer(Murl.SharedPointer.NetISocketPacketConst serverBroadcast)

Parameters
serverBroadcastThe broadcast packet received by GetServerBroadcast().
Returns
Boolean true if removing the packet from the broadcast queue was successful.

ConnectToServer(address, name, uniqueId)

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)

Parameters
addressThe server address to connect to.
nameThe name of the server.
uniqueIdThe unique identifier of the server.
Returns
Boolean true if passing the command was successful.

DisconnectServer()

Disconnect from the server.

Boolean DisconnectServer()

Returns
Boolean true if passing the command was successful.

IsConnectedOrConnecting()

Check if the client is connected to a server or connecting to the server is in progress.

Boolean IsConnectedOrConnecting()

Returns
Boolean true if the client is connected to a server or connecting to the server is in progress.

IsConnected()

Check if the client is connected to a server.

Boolean IsConnected()

Returns
Boolean true if the client is connected to a server.

GetServerInfo()

Get detailed information of a connected server.

Murl.SharedPointer.NetISocketPacket GetServerInfo()

Returns
Murl.SharedPointer.NetISocketPacket The server information packet.

Send(data)

Send data to the server.

Boolean Send(Murl.ConstData data)

Parameters
dataThe data object to send.
Returns
Boolean true if passing the data was successful, false if the client is not connected.

GetMaxReceiveQueueLength()

Get the maximum number of received packets the thread can store. The default received packets queue length is 20.

Integer GetMaxReceiveQueueLength()

Returns
Integer The maximum number of received packets the thread can store.

SetMaxReceiveQueueLength(maxLength)

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)

Parameters
maxLengthThe maximum number of received packets the thread can store.

ClearReceiveQueue()

Clear the received packets queue.

ClearReceiveQueue()


GetReceivedData()

Get a received packet from a server. The packet returned is removed from the received packets queue.

Murl.SharedPointer.NetISocketPacket GetReceivedData()

Returns
Murl.SharedPointer.NetISocketPacket A received packet from a server or null if the received packets queue is empty.


Metamethods


The tostring operator

Converts the object content to a string in a reasonable format.

Returns
GetClientName()