Skip to main content

.NET (C#) SDK Initialization

Last updated on

Use following .NET namespaces:

using AccelByte.Sdk.Api.Lobby;
using AccelByte.Sdk.Api.Lobby.WSModel;

The Lobby WebSocket service works slightly differently to other AccelByte services. Before using the Lobby WebSocket service, you will need to create a LobbyService object.

LobbyService lobby = new LobbyService(sdk.Configuration);
lobby.OnReceiveError = (eMessage) =>
{
is_error = true;
//handle if error occurs here
};

Once completed, you can connect and listen to the Lobby WebSocket service.

Task connectTask = lobby.Connect(false);
connectTask.Wait();

Task listenTask = Task.Run(() => lobby.Listen());