This is a helper method to get the current post id.
This is a helper method to get the Reddit API client. You can use this to interact with Reddit.
This is a helper method to get the Redis client. All of your game state should be stored in Redis.
This is a helper method to get the current user id. This will be null if the user is not logged in, or if this is a TimerEvent handler.
Cancels a scheduled timer event
The timer event to cancel
Called when a player writes to a synchronized data manager from the client. Override this method to do permission checks or other setup. In particular, you can check this.userId, etc, to see if the player is allowed to write to this data. If not, throw an error to prevent the write.
Called when a player creates a synchronized data manager from the client. Override this method to do permission checks or other setup. In particular, you can check this.userId, etc, to see if the player is allowed to view this data. If not, throw an error to prevent the creation.
This method is called when a new post is created. You can use this to initialize the game state.
The post that was created.
This method is called when a message is received from the broadcast channel. By default, this will send the message to the webview. You can override this method to customize the behavior.
The message that was received from the broadcast channel.
This gets called whenever a timer event is triggered. You can use this to update the game state, broadcast changes, etc. By default, this method broadcasts the timer event to the postId channel.
This method is called when a message is received from the webview. You can use this to update the game state. By default, this method will broadcast the message to the postId channel. You can override this method to customize the behavior.
The message that was sent from the webview.
Assuming you're in an individual user's context, you can use this method to send a message to the webview. If you're in a more global context, like a timer event, there won't be a webview to send a message to, so this will do nothing.
The message to send to the webview. This should be a JSONable object.
Schedules a recurring timer event on the server. You should prefer this to naive setInterval, if you want a long-running interval. This method will handle server restarts and other issues that could cause a naive setInterval to drift or stop.
Unique identifier for the timer, used for cancellation
Interval in milliseconds between timer events
Optional data: JSONValueOptional data to pass to the timer event
A TimerEvent object representing the scheduled timer
Error if no postId is present in the context
Schedules a one-time timer event. You should prefer this to naive setTimeout, if you want a long-running timer. This method will handle server restarts and other issues that could cause a naive setTimeout to drift or stop.
Unique identifier for the timer, used for cancellation
Delay in milliseconds before the timer fires
Optional data: JSONValueOptional data to pass to the timer event
A TimerEvent object representing the scheduled timer
Error if no postId is present in the context
Protected to
A GameServer subclass for Phaser games. This class adds some additional methods for managing synchronized data managers, which are the primary way to do multiplayer communication.