Reference Source Test
public class | source

Socket

Connect to the server via websockets

Constructor Summary

Public Constructor
public

constructor(instance: Game)

Default constructor

Member Summary

Public Members
public

Pulls out the client configuration from the Game instance

public

IO websocket connection

public

Whether or not this websocket has disconnected

public

Instance of the game

public

Whether or not this websocket is listening

public

Array of messages sent from the nodeJS server to the client side game

Method Summary

Public Methods
public

Loads the connection, attempts to create the websocket

public

receive(message: Messages)

Gets a message from the server

public

send(packet: Packets, data: Object)

Sends a data packet from the client side to the server side

Public Constructors

public constructor(instance: Game) source

Default constructor

Params:

NameTypeAttributeDescription
instance Game

of the game

Public Members

public config: Object source

Pulls out the client configuration from the Game instance

public connection: Object source

IO websocket connection

public disconnected: Boolean source

Whether or not this websocket has disconnected

public game: Game source

Instance of the game

public listening: Boolean source

Whether or not this websocket is listening

public messages: Messages[] source

Array of messages sent from the nodeJS server to the client side game

Public Methods

public connect() source

Loads the connection, attempts to create the websocket

public receive(message: Messages) source

Gets a message from the server

Params:

NameTypeAttributeDescription
message Messages

a single message object

public send(packet: Packets, data: Object) source

Sends a data packet from the client side to the server side

Params:

NameTypeAttributeDescription
packet Packets

type of data to send to the server

data Object

object which will be stringified as JSON before it is sent to the server