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

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.


Table members

Methods


GetServerName()

Get the name of the server.

String GetServerName()

Returns
String The name of the server.

GetUniqueIdentifier()

Get the unique identifier of the server.

String GetUniqueIdentifier()

Returns
String The unique identifier of the server.

StartListen(address)

Start listening for incoming ISocketClient connections.

Boolean StartListen(Murl.SharedPointer.NetISocketAddressConst address)

Parameters
addressThe address to bind for listening.
Returns
Boolean true if passing the address was successful.

StopListen()

Stop listening for incomming ISocketClient connections.

Boolean StopListen()

Returns
Boolean true if passing the command was successful.

StartSendBroadcast(address)

Start sending broadcasts. Before starting broadcasts the listen address must be set by StartListen().

Boolean StartSendBroadcast(Murl.SharedPointer.NetISocketAddressConst address)

Parameters
addressThe address to send the broadcast.
Returns
Boolean true if passing the address was successful.

StopSendBroadcast()

Stop sending broadcasts.

Boolean StopSendBroadcast()

Returns
Boolean true if passing the address was successful.

SetBroadcastClock(clockTime)

Set the broacast clock time. The default clock time is 1 second. Every clockTime seconds one broadcast packet is sent.

SetBroadcastClock(Number clockTime)

Parameters
clockTimeThe broacast send clock time in seconds.

GetMaxAcceptQueueLength()

Get the maximum number of accept packets the thread can store. The default accept packets queue length is 50.

Integer GetMaxAcceptQueueLength()

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

SetMaxAcceptQueueLength(maxLength)

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)

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

ClearAcceptQueue()

Clear the accept packets queue.

ClearAcceptQueue()


GetClientToAccept()

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

Returns
Murl.SharedPointer.NetISocketPacketConst An accept packet from a client or null if the accept packet queue is empty.

AcceptClient(clientToAccept)

Accept a client connection.

Boolean AcceptClient(Murl.SharedPointer.NetISocketPacketConst clientToAccept)

Parameters
clientToAcceptThe accept packet received by GetClientToAccept().
Returns
Boolean true if accepting the client was successful.

DenyClient(clientToDeny)

Deny a client accept packet.

Boolean DenyClient(Murl.SharedPointer.NetISocketPacketConst clientToDeny)

Parameters
clientToDenyThe accept packet received by GetClientToAccept().
Returns
Boolean true if removing the packet from the accept queue was successful.

GetNumberOfConnectedClients()

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

Returns
Integer The number of connected clients.

HasAcceptedClientsChanged(inspector)

Check if the accepted clients list has changed.

Boolean, Murl.ChangeInspector HasAcceptedClientsChanged(Murl.ChangeInspector inspector)

Parameters
inspectorThe inspector to check.
Returns
Boolean true if the accepted clients list has changed.
Murl.ChangeInspector inspector The inspector to check.

GetAcceptedClients(clientIds)

Get the unique identifiers of all accepted clients. Use HasAcceptedClientsChanged() to check for changes.

Murl.Array.String GetAcceptedClients(Murl.Array.String clientIds)

Parameters
clientIdsThe identifier string array return value.
Returns
Murl.Array.String clientIds The identifier string array return value.

GetClientInfo(clientId)

Get detailed information of a connected client. The GetAcceptedClients() method returns all accepted client identifiers.

Murl.SharedPointer.NetISocketPacket GetClientInfo(String clientId)

Parameters
clientIdThe unique identifier of the client.
Returns
Murl.SharedPointer.NetISocketPacket The client information packet or null if the identifier is not found.

Disconnect(clientId)

Disconnect a client. The GetAcceptedClients() method returns all accepted client identifiers.

Boolean Disconnect(String clientId)

Parameters
clientIdThe unique identifier of the client.
Returns
Boolean true if passing the command was successful, false if the client is not found.

Send(data, clientId)

Send data to a client. The GetAcceptedClients() method returns all accepted client identifiers.

Boolean Send(Murl.ConstData data, String clientId)

Parameters
dataThe data object to send.
clientIdThe unique identifier of the client.
Returns
Boolean true if passing the data was successful, false if the client is not found.

GetMaxReceiveQueueLength()

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

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. 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 client. The packet returned is removed from the received packets queue.

Murl.SharedPointer.NetISocketPacket GetReceivedData()

Returns
Murl.SharedPointer.NetISocketPacket A received packet from a client 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
GetServerName()