Client information class.

Constructor

new (s:Socket, srv:Server)

Fields

read only connectionID:Int

Unique connection ID. Used for asynchronous responses when the client did not login yet.

id:Int

Client ID. In the case of game server it is set to user ID on successful client login.

isLogin:Bool

Set to true by the server on successful client login. Treat as read-only in most cases.

isOnline:Bool

Set to true by the server when the client socket is connected. Treat as read-only in most cases.

lang:String

Client language. In the case of game server it is set to a given language on successful client login.

name:String

Client name. In the case of game server it is set to user name on successful client login.

platform:String

Client platform. In the case of game server it is set to a given platform on successful client login.

read only server:Server

Server variable.

read only socket:Socket

Client socket.

Methods

dynamic callPost (type:String, params:Params, response:Dynamic):Void

Called after each client request. Needs to be overriden.

Parameters:

type

Request type.

params

Request parameters.

response

Request response. Can be modified.

dynamic disconnect ():Void

Called on client disconnect. Needs to be overriden.

dynamic free ():Void

This method should update and unlock all additional client blocks. Called on client disconnect if the client is online and after Server.onCacheNotify() if the client is offline. Needs to be overriden.

get (name:String):Dynamic

Returns client variable value. Client variables live only until the end of session.

Parameters:

name

Variable name.

Returns:

Variable value. Returns null if the variable does not exist.

getBool (name:String):Bool

Returns client variable value as Bool. Client variables live only until the end of session.

Parameters:

name

Variable name.

Returns:

Variable value. Returns false if the variable does not exist.

getFloat (name:String):Float

Returns client variable value as Float. Client variables live only until the end of session.

Parameters:

name

Variable name.

Returns:

Variable value. Returns 0 if the variable does not exist.

getIP ():String

Returns client IP address.

Returns:

Client IP address. If socket is not connected, returns an empty string. If socket is null, returns ?dc? string.

getInt (name:String):Int

Returns client variable value as Int. Client variables live only until the end of session.

Parameters:

name

Variable name.

Returns:

Variable value. Returns 0 if the variable does not exist.

getString (name:String):String

Returns client variable value as String. Client variables live only until the end of session.

Parameters:

name

Variable name.

Returns:

Variable value. Returns an empty string if the variable does not exist.

isLocal ():Bool

Returns true if this client has a local IP address.

Returns:

True, if this client has a local IP address. False otherwise.

inline notify (msg:Dynamic):Void

Adds message to notification queue.

Any pending notifications will be sent with the next client response in serverNotify parameter as a List<Dynamic>. Each 3 seconds the server checks if there are any messages in the notification queue. If there are, the client response with the type server.notify is sent.

Parameters:

msg

Notification to send to client.

response (type:String, params:Dynamic):Void

Sends response to this client. This method is thread-safe.

Note: If the client is not online, this method will fail silently.

Parameters:

type

Response type.

params

Response parameters.

set (name:String, val:Dynamic):Void

Sets client variable. Client variables live only until the end of session.

Parameters:

name

Variable name.

val

Variable value.