Operations & Events | Unity Realtime

The Gamedonia Realtime SDK uses operations to send information from the client to the server. They are are sent using the sendOp method of the GamedoniaRT singleton class. Once they get to the server, a response comes back to the client through specific events. These operations and events are listed in the next catalog:

Login

This operation identifies the client to the real-time server. As a result, the GamedoniaRT singleton will store a representation of the connected user at the me property. You can send different credential types but none of them is required. If a credential is specified, then it will be validated against the Gamedonia Backend. If you don't specify a credential, no extra validation against Gamedonia Backend is done.

Message

  • name. Type string. Required. User name that will be displayed inside the room. Unique field.
  • type. Type short. Optional. Credential types available:
    • email (0)
    • facebook (1)
    • silent (2)
    • gamecenter (3)
    • twitter (4)
    • session_token (5)
  • email. Type string. Email credentials. You must also specify a password.
  • password. Type string. Password Credential. Needs also an email.
  • fbuid. Type string. Facebook Id. Needs a Facebook access token.
  • fbAccessToken. Type string. Facebook access token. Needs a Facebook uid.
  • silent. Type string. Device Unique Id.
  • gamecenterId. Type string. Game Center id.
  • twuid. Type string. Twitter user id. Needs a Twitter token.
  • twtoken. Type string. Twitter token. Needs a twuid.
  • session_token. Type string. Gamedonia session Token.

Events

ON_LOGIN_SUCCESS

Login success event.

  • myself. Type User. Representation of the user that has been logged in to the server.

ON_LOGIN_ERROR

Login error event:

  • error. Type string. Error description.
  • code. Type int. Error code.

Logout

Operation sent by a user to leave a game. The client is still connected but the game doesn’t keep any reference to the user. If the user was in a room at the moment of logout, then he also leaves the room.

Message

This operation doesn't use any parameters.

Events

ON_LOGOUT_SUCCESS

Logout success event.

No data included in the response.

ON_LOGOUT_ERROR

Logout error event:

  • error. Type string. Error description.
  • code. Type int. Error code.

Create Room

This operation allows a user to create a new room for your game. The room name is unique.

Message

Create Room takes just one single complex property as parameter.

  • roomSettings. Type RoomSettings. Includes all the configurable parameters of a room.

The type RoomSettings includes the following properties:

  • name. Type string. Room name. Unique.
  • groupId. Type string. Group to which the room belongs. By default the room belongs to the default group.
  • maxUsers. Type int. Maximum number of player users allowed in the room.
  • maxSpectators. Type int. Maximum number of spectators allowed in the room.
  • isGame. Type bool. Indicates whether the room is a game room.
  • isHidden. Type bool. Indicates if the room is visible to all the users in the same room group. The user must know the room name to be able to join a hidden room.
  • removePolicy. Type short. Indicates the policy to apply to the room when empty.
  • password. Type string. Password required to access the room.

Events

ON_CREATE_ROOM_SUCCESS

Create Room success event.

  • room. Type Room. The room content. It contains all the room variables to which we have access.

ON_CREATE_ROOM_ERROR

Login error event:

  • error. Type string. Error description.
  • code. Type int. Error codes:
    • 601: Room already exists.
    • 602: Invalid parameters in Create Room Message.
    • 999: Unexpected Create Room message.

ON_ROOM_ADDED_TO_GROUP

Event notified to all the users in the group where the room was created. The rooms manager tracks the new room.

  • room. Type Room. The room content. It contains all the room variables to which we have access.

Join Room

This operation lets users become part of an already created room. Users can be at several rooms simultaneously.

Message

  • roomId. Type long. Identifier of the room we want to join.
  • mode. Type short. Modes:
    • As Player (1)
    • As Spectator (2)
  • password. Type string. Optional. It only applies to rooms protected by a password.

Events

ON_JOIN_ROOM_SUCCESS

Join Room success event. It's received only by the user that sent the Join Room Operation.

  • room. Type Room. The details of the joined room.

ON_JOIN_ROOM_ERROR

Join Room error event:

  • error. Type string. Error description.
  • code. Type int. Error codes:
    • 801: Room is full.
    • 802: User already exists in the room.
    • 803: Wrong password.
    • 804: Room not found.
    • 999: Unexpected Join Room message.

ON_USER_JOINED_ROOM

This event is sent to all users who are already in the room when another user joins.

  • roomId. Type long. Identifier of the room where a new user joined.
  • user. Type User. User that joined the room.

Leave Room

Operation sent by a user that wants to leave a room he joined before.

Message

  • roomId. Type long. Identifier of the room to leave. The user must already be in the room.

Events

ON_LEAVE_ROOM_SUCCESS

Leave Room success event.

  • room. Type Room. Details of the room just left.

ON_LEAVE_ROOM_ERROR

Leave Room error event:

  • error. Type string. Error description.
  • code. Type int. Error codes:
    • 901: Error leaving room, wrong id.
    • 999: Unexpected Leave Room message.

ON_USER_LEFT_ROOM

Event sent to all other room members when a user leaves the room.

  • roomId. Type long. Identifier of the room left by a user.
  • user. Type User. User that left the room.

ON_ROOM_WAS_CLOSED

Event triggered when a room becomes empty after a user leaves it.

  • room. Type Room. Details of the room that was closed.

SetUserVariables

Operation used to create or modify a user variable.

Message

  • name. Type string. Unique name that identifies the variable.
  • value. Type varying. Contains the value of the variable.
  • type. Type byte. Variable type:
    • OBJECT
    • ARRAY
    • STRING
    • DOUBLE
    • INT
    • BOOL
    • EMPTY
  • mode. Type short. Modes:
    • Full Access (0): Synchronized with all users in the room. All Users can edit its content.
    • Shared (1): Synchronized with all users in the room but can only be modified by the owner.
    • Private (2): Synchronized only with the owner and can only be modified by the owner.
    • Read Only (3): Syncrhonized with all users in the room and can only be modified by the room extension (Coming soon feature).

Events

ON_SET_USER_VARIABLES_SUCCESS

SetUserVariables success event.

  • user. Type User. User that changed his variables.
  • changedVarNames. Type long. Names of the variables that got their value changed.

ON_SET_USER_VARIABLES_ERROR

SetUserVariables error event:

  • error. Type string. Error description.
  • code. Type int. Error codes:
    • 999: Unexpected SetUserVariables message.

SetRoomVariables

Updates or creates a room variable. This is equivalent to SetUserVariables. Room variables are stored linked to the room, not to a particular user.

Message

  • name. Type string. Unique name that identifies the variable.
  • value. Type varying. Contains the value of the variable.
  • type. Type byte. Variable type:
    • OBJECT
    • ARRAY
    • STRING
    • DOUBLE
    • INT
    • BOOL
    • EMPTY
  • mode. Type short. Modes:
    • Full Access (0): Synchronized with all users in the room. All Users can edit its content.
    • Shared (1): Synchronized with all users in the room but can only be modified by the owner.
    • Private (2): Synchronized only with the owner and can only be modified by the owner.
    • Read Only (3): Syncrhonized with all users in the room< and can only be modified by the room extension (Coming soon feature).

Events

ON_SET_ROOM_VARIABLES_SUCCESS

SetRoomVariables success event.

  • user. Type User. Room that changed its variables.
  • changedVarNames. Type long. Names of the variables that got their value changed.

ON_SET_ROOM_VARIABLES_ERROR

SetRoomVariables error event:

  • error. Type string. Error description.
  • code. Type int. Error codes:
    • 999: Unexpected SetUserVariables message.