Master Server Kit Client Api

From gamevanilla wiki
Jump to: navigation, search

ClientAPI

The ClientAPI class is the client-side entry point to all of the functionality available in Master Server Kit. It provides the following methods:

FindGameRooms

   void FindGameRooms(
       List<Property> includeProperties,
       List<Property> excludeProperties,
       Action<SpawnedGameNetwork[]> callback)

Description

Finds all the registered game rooms. You can do filtering on the game rooms that have the properties you are interested in.

Parameters

  • includeProperties: The properties that the game rooms should have.
  • excludeProperties: The properties that the game rooms should not have.
  • callback: The callback to execute when the rooms have been found. This callback will receive the list of returned game rooms as a parameter.

CreateGameRoom

   void CreateGameRoom(
       string name,
       int maxPlayers,
       string password,
       Action<string, int> successCallback,
       Action<CreateGameRoomError> errorCallback)

Description

Creates a new game room.

Parameters

  • name: The name of this room.
  • maxPlayers: The maximum number of players allowed in this room.
  • password: The password of this room (can be null for public rooms).
  • successCallback: The callback to execute when the room has been successfully created. This callback will receive both the IP address and the port number of the spawned game server instance as parameters.
  • errorCallback: The callback to execute when the room has not been successfully created. This callback will receive the error as a parameter.

CreateGameRoom

   void CreateGameRoom(
       string name,
       int maxPlayers,
       string password,
       List<Property> properties,
       Action<string, int> successCallback,
       Action<CreateGameRoomError> errorCallback)

Description

Creates a new game room with the specified properties.

Parameters

  • name: The name of this room.
  • maxPlayers: The maximum number of players allowed in this room.
  • password: The password of this room (can be null for public rooms).
  • properties: The properties of this room.
  • successCallback: The callback to execute when the room has been successfully created. This callback will receive both the IP address and the port number of the spawned game server instance as parameters.
  • errorCallback: The callback to execute when the room has not been successfully created. This callback will receive the error as a parameter.

JoinGameRoom

   void JoinGameRoom(
       int roomId,
       string password,
       Action<string, int> successCallback,
      Action<JoinGameRoomError> errorCallback)

Description

Joins an existing game room with the specified id.

Parameters

  • roomId: The unique identifier of the room to join.
  • password: The password of the room to join (can be null for public rooms).
  • successCallback: The callback to execute when the room has been successfully joined. This callback will receive both the IP address and the port number of the spawned game server instance as parameters.
  • errorCallback: The callback to execute when the room has not been successfully joined. This callback will receive the error as a parameter.

PlayNow

   void PlayNow(
       Action<string, int> joinCallback,
       Action<string, int> createSuccessCallback,
       Action<CreateGameRoomError> createErrorCallback)

Description

Joins an existing available game room or creates a new one if none is available.

Parameters

  • joinCallback: The callback to execute when an available room has been successfully joined. This callback will receive both the IP address and the port number of the spawned game server instance as parameters.
  • createSuccessCallback: The callback to execute when a room has been successfully created. This callback will receive both the IP address and the port number of the spawned game server instance as parameters.
  • createErrorCallback: The callback to execute when a room has not been successfully created. This callback will receive the error as a parameter.

JoinGameServer

   void JoinGameServer(
       string ip,
       int port,
       Action onConnected)

Description

Joins the game server with the specified IP address and port number. Use this method if you are not using the Network Manager component available in UNET.

Use the callback to transition between your lobby scene and your game scene as appropriate in the context of your game.

Parameters

  • ip: The IP address of the game server to join.
  • port: The port of the game server to join.
  • onConnected: The callback to execute when the game server has been joined.

JoinGameServer (when using the Network Manager component)

   void JoinGameServer(
       string ip,
       int port)

Description

Joins the game server with the specified IP address and port number via the specified Network Manager object. Use this method if you are using UNET's high-level API for your game's networking code.

The transition between your lobby scene and your game scene will be performed automatically by the Network Manager object.

Parameters

  • ip: The IP address of the game server to join.
  • port: The port of the game server to join.

GetIntProperty

   void GetIntProperty(
       string name,
       Action<int> successCallback)

Description

Returns the value of the integer player property with the specified name.

Parameters

  • name: The name of the integer player property.
  • successCallback: The callback to execute when the property is retrieved.

GetStringProperty

   void GetStringProperty(
       string name,
       Action<int> successCallback)

Description

Returns the value of the string player property with the specified name.

Parameters

  • name: The name of the string player property.
  • successCallback: The callback to execute when the property is retrieved.