Amazon GameLift
Developer Guide (Version )

The AWS Documentation website is getting a new look!
Try it now and let us know what you think. Switch to the new look >>

You can return to the original look by selecting English in the language selector above.

Realtime Servers Client API (C#) Reference: Asynchronous Callbacks

Use this C# Realtime Client API reference to help you prepare your multiplayer game for use with Realtime Servers deployed on Amazon GameLift fleets. For details on the integration process, see Get Started with Realtime Servers.

A game client needs to implement these callback methods to respond to events. The Realtime server invokes these callbacks to send game-related information to the game client. Callbacks for the same events can also be implemented with custom game logic in the Realtime server script. See Script Callbacks for Realtime Servers.

Callback methods are defined in ClientEvents.cs.

OnOpen()

Invoked when the server process accepts the game client's connection request and opens a connection.

Syntax

public void OnOpen()

Parameters

This method takes no parameters.

Return Value

This method does not return anything.

OnClose()

Invoked when the server process terminates the connection with the game client, such as after a game session ends.

Syntax

public void OnClose()

Parameters

This method takes no parameters.

Return Value

This method does not return anything.

OnError()

Invoked when a failure occurs for a Realtime Client API request. This callback can be customized to handle a variety of connection errors.

Syntax

private void OnError(byte[] args)

Parameters

This method takes no parameters.

Return Value

This method does not return anything.

OnDataReceived()

Invoked when the game client receives a message from the Realtime server. This is the primary method by which messages and notifications are received by a game client.

Syntax

public void OnDataReceived(DataReceivedEventArgs dataReceivedEventArgs)

Parameters

dataReceivedEventArgs

Information related to message activity.

Type: DataReceivedEventArgs

Required: Yes

Return Value

This method does not return anything.

OnGroupMembershipUpdated()

Invoked when the membership for a group that the player belongs to has been updated. This callback is also invoked when a client calls RequestGroupMembership.

Syntax

public void OnGroupMembershipUpdated(GroupMembershipEventArgs groupMembershipEventArgs)

Parameters

groupMembershipEventArgs

Information related to group membership activity.

Type: GroupMembershipEventArgs

Required: Yes

Return Value

This method does not return anything.