This module provides client request functionality for rooms.

It is available only on Snipe Kit server.

Constructor

Methods

broadcast (c:RoomClientKit, params:Params):{errorCode:String}

kit/room.broadcast

Broadcasts a message to all users in the room that this client is in.

Will not send a standard response to the client that sent the broadcast in case of success.

Upon successful broadcast all clients in the room will receive the message with the type "kit/room.broadcast" and message contents in "msg" field.

Input:

Output:

  • errorCode - String. Operation error code.

Error codes:

  • notInRoom - This client has not joined a room.
  • roomDead - This room is dead.

event (c:RoomClientKit, params:Params):{errorCode:String}

kit/room.event

Sends a client event to the room event handler that this client is currently in.

Input:

  • actionID - String. Event action string ID.
  • Other event parameters. Will be passed to event handler.

Output:

  • errorCode - String. Operation error code. Has to be supplied in event handler.
  • Event handler custom return object fields.

Error codes:

  • notInRoom - This client has not joined a room.
  • noSuchAction - This game type does not have an event action with this string ID.
  • roomDead - This room is dead.
  • Event handler custom error codes.

join (c:RoomClientKit, params:Params):{errorCode:String}

kit/room.join

Adds this user to the specified room of a given game type. If room join action exists, it will be called and its results will be returned to the client.

Note: A user can only be in one room.

Input:

  • typeID - String. Game type ID.
  • roomID - Int. Room ID.

Output:

  • errorCode - String. Operation error code.
  • Fields defined by room join action.

Error codes:

  • ok - Operation successful.
  • roomNotFound - Room with this ID was not found.
  • joinNotAllowed - This user is not allowed to join this room.
  • alreadyInRoom - This user is already in another room.
  • Error codes defined by room join action.

leave (c:RoomClientKit, params:Params):{errorCode:String}

kit/room.leave

Removes this user from the room he is currently in.

All of room clients will receive "kit/room.left" message with userID set.

Client state on game server will be reset.

Input:

Output:

  • errorCode - String. Operation error code.

Error codes:

  • ok - Operation successful.
  • notInRoom - This user is not in a room.