PlayerSession

Session for players.

class PlayerSession {}

Constructors

this
this(HubServer server, Client client)
Undocumented in source.

Members

Functions

connect
bool connect(ubyte reason, int nodeId, ubyte[] message, ubyte onFail)

Tries to connect the player to a node. This function does not notify the old node of the change, as the old node should have called the function.

endOfStream
void endOfStream()

Function called when the player tries to connect to a node that doesn't exist, either because the name is wrong or because there aren't available ones.

firstConnect
bool firstConnect()

Calls the connect function using 'first join' as reason and, if it successfully connects to a node, add the player to the server.

hncomAddData
JSONValue hncomAddData()
Undocumented in source. Be warned that the author may not have intended to support it.
kick
void kick(string reason, bool translation, string[] params)

Function called when the player is kicked (by the hub or the node). The function should send a disconnection message and close the session.

onClosed
void onClosed()
Undocumented in source. Be warned that the author may not have intended to support it.
onClosedByClient
void onClosedByClient()

Function called when the connection is manually closed by the client clicking the disconnect button on the game's interface.

onKicked
void onKicked(string reason)

Function called when the client is kicked from the hub (not from the node).

onTimedOut
void onTimedOut()

Function called when the client times out.

sendFromNode
void sendFromNode(ubyte[] payload)

Sends an encoded packet to client that has been created and encoded by the node.

sendLatency
void sendLatency()

Sends the latency to the connected node.

sendOrderedFromNode
void sendOrderedFromNode(uint order, ubyte[] payload)

Sends a packet from the node and mantains the order.

sendPacketLoss
void sendPacketLoss()

Sends the packet loss to the connected node.

sendToNode
void sendToNode(ubyte[] payload)

Forwards a game packet to the node.

transfer
void transfer(uint node)

Function called when the player is manually transferred by the hub to a node.

Properties

address
Address address [@property getter]

Gets the player's remote address. it's usually an ipv4, ipv6 or an ipv4-mapped ipv6.

dimension
byte dimension [@property getter]

Gets the player's world, which is updated by the node every time the client changes dimension.

displayName
string displayName [@property getter]
string displayName [@property setter]

Gets and sets the player's display name. It can contain formatting codes and it could change during the session's lifetime (if modified by a node). It's usually displayed in the nametag and in the players list.

game
string game [@property getter]

Gets the game type and version as a human-readable string.

gameName
string gameName [@property getter]

Gets the client's game name.

gameVersion
string gameVersion [@property getter]

Gets the client's game version, which could either be calculated from the protocol number or given by the client.

id
uint id [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
inputMode
InputMode inputMode [@property getter]

Gets the player's input mode.

iusername
string iusername [@property getter]

Gets the player's lowercase username.

language
string language [@property getter]

Gets/sets the player's language, indicated as code_COUNTRY.

language
string language [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
latency
uint latency [@property getter]

Gets the player's latency. Not being calculated using an ICMP protocol the value may not be completely accurate.

packetLoss
float packetLoss [@property getter]

Gets the player's latency. It returns a floating point value between 0 and 100 where 0 is no packet loss and 100 is every packet lost since the last check. If the client uses a stream-oriented connection the value will always be 0.

permissionLevel
ubyte permissionLevel [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
permissionLevel
ubyte permissionLevel [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
protocol
uint protocol [@property getter]

Gets the protocol number used by the client. It may be 0 if the packet with the protocol number didn't come yet.

serverIp
string serverIp [@property getter]

IP used by the client to connect to the server. It's a string and can either be a numerical ip or a full url.

serverPort
ushort serverPort [@property getter]

Port used by the client to connect to the server.

skin
Skin skin [@property getter]

Gets the player's skin as a Skin object. If the player has no skin the object will be null.

suuid
const(suuid_t) suuid [@property getter]

Gets the SEL UUID, a unique identifier for the player in the session. It's composed by 17 bytes (type and UUID) and it will never change for authenticated players.

type
ubyte type [@property getter]

Gets the game type as an unsigned byte identifier. The types are indicated in module sel.server.client, in the Client's class.

username
string username [@property getter]

Gets the player's username, mantaining the case given by the login packet. It doesn't change during the life of the session.

uuid
UUID uuid [@property getter]

Gets the UUID. It's unique when online-mode is se to true and can be used to identify a player. When online-mode is set to false it is randomly generated and its uses are very limited.

viewDistance
ubyte viewDistance [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
viewDistance
ubyte viewDistance [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
world
shared(World) world [@property getter]

Gets the player's world, which is updated by the node every time the client changes dimension.

world
World world [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

_dimension
ubyte _dimension;
Undocumented in source.
_display_name
string _display_name;
Undocumented in source.
_language
string _language;
Undocumented in source.
_permission_level
ubyte _permission_level;
Undocumented in source.
_skin
Skin _skin;
Undocumented in source.
_view_distance
ubyte _view_distance;
Undocumented in source.
_world
World _world;
Undocumented in source.
lower_username
string lower_username;
Undocumented in source.

Meta