extends pc.EventHandler
Main interface of PlayNetwork server. This class handles clients connection and communication.
.id : number
.users : Users
.rooms : Rooms
.networkEntities : Map<number
, NetworkEntity>
.cpuLoad : number
.memory : number
error => (error)
* => (sender, [data], callback)
start(settings) [async]
.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.
.networkEntities : Map<number
, NetworkEntity>
Map of all NetworkEntitys created by this server.
.cpuLoad : number
Current CPU load 0..1.
.memory : number
Current memory usage in bytes.
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. |
start(settings) [async]
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. |
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. |