Skip to content

Latest commit

 

History

History
122 lines (81 loc) · 3.86 KB

PlayNetwork.md

File metadata and controls

122 lines (81 loc) · 3.86 KB

PlayNetwork (server)

extends pc.EventHandler

Main interface of PlayNetwork server. This class handles clients connection and communication.


Index

Properties

.id : number
.users : Users
.rooms : Rooms
.networkEntities : Map<number, NetworkEntity>
.cpuLoad : number
.memory : number

Events

error => (error)
* => (sender, [data], callback)

Functions

start(settings) [async]


Properties

.id : number

Numerical ID of the server.

Users interface that stores all connected users.

Rooms interface that stores all rooms and handles new Rooms creation.

Map of all NetworkEntitys created by this server.

.cpuLoad : number

Current CPU load 0..1.

.memory : number

Current memory usage in bytes.

Events

error [event] => (error)

Unhandled error.

Param Type Description
error Error Error object.

* [event] => (sender, [data], callback)

PlayNetwork will receive own named network messages. Those messages are sent by the clients.

Param Type Description
sender User User that sent the message.
data object | array | string | number | boolean Message data.
callback responseCallback Callback that can be called to respond to a message.

Functions

Start PlayNetwork, by providing configuration parameters.

Param Type Description
settings object Object with settings for initialization.
settings.redisUrl string URL of a Redis server.
settings.websocketUrl string Publicly or inter-network accessible URL to this servers WebSocket endpoint.
settings.scriptsPath string Relative path to script components.
settings.templatesPath string Relative path to templates.
settings.levelProvider object Instance of a level provider.
settings.server http.Server | https.Server Instance of a http(s) server.

Callbacks

responseCallback [callback] => (error, data)

Param Type Description
error null | [Error] Error provided with a response.
data null | object | array | string | number | boolean Data provided with a response.