Class: Room<StateProps, MoreMessageTypes>
Type parameters
Name | Type |
---|---|
StateProps | Record <string , any > |
MoreMessageTypes | extends Record <string , unknown > = Record <string , unknown > |
Constructors
constructor
• new Room<StateProps
, MoreMessageTypes
>(room
)
Type parameters
Name | Type |
---|---|
StateProps | Record <string , any > |
MoreMessageTypes | extends Record <string , unknown > = Record <string , unknown > |
Parameters
Name | Type |
---|---|
room | colyseusRoom |
Properties
room
• room: colyseusRoom
Accessors
id
• get
id(): string
Returns
string
sessionID
• get
sessionID(): string
Returns
string
state
• get
state(): ClientGameState
<StateProps
>
Returns
ClientGameState
<StateProps
>
Methods
destroy
▸ destroy(): void
Returns
void
leave
▸ leave(): void
Returns
void
onError
▸ onError(code
, message
): void
Parameters
Name | Type |
---|---|
code | number |
message | string |
Returns
void
onFirstStateChange
▸ onFirstStateChange(state
): void
Parameters
Name | Type |
---|---|
state | ClientGameState <StateProps > |
Returns
void
onLeave
▸ onLeave(code
): void
Parameters
Name | Type | Description |
---|---|---|
code | number | webSocket shutdown code |
Returns
void
onMessage
▸ onMessage<M
, T
>(type
, callback
): () => void
Subscribe to messages from the server
Type parameters
Name | Type |
---|---|
M | extends RecordOfServerMessages <MoreMessageTypes & { * : unknown }> & ServerMessageTypes |
T | extends string | number | symbol |
Parameters
Name | Type |
---|---|
type | T |
callback | (message : M [T ]) => void |
Returns
fn
method to unsubscribe
▸ (): void
Subscribe to messages from the server
Returns
void
method to unsubscribe
onStateChange
▸ onStateChange(state
): void
Parameters
Name | Type |
---|---|
state | ClientGameState <StateProps > |
Returns
void
send
▸ send<T
>(type
, message?
): void
Send a custom message from client to server.
Type parameters
Name | Type |
---|---|
T | extends keyof ClientMessageTypes |
Parameters
Name | Type |
---|---|
type | T |
message? | ClientMessageTypes [T ] |
Returns
void
sendInteraction
▸ sendInteraction(interaction
, entityIdxPath
, data?
): void
Sends an event related to entity interaction.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
interaction | InteractionType | undefined | - |
entityIdxPath | number [] | undefined | idx path to entity of interaction |
data | any | undefined | - |
Returns
void