Handle the Connect/Disconnect Event
Last updated on
This feature notifies the game of any changes to the connection to the Lobby server. The SDK already provides an auto-reconnect mechanism, but when the auto-reconnect times out you must reconnect manually.
- Unreal Engine
- Unity
FRegistry::Lobby.Connect();
FRegistry::Lobby.SetConnectSuccessDelegate(AccelByte::Api::Lobby::ConnectSuccess.CreateLambda([]()
{
// Do something If ConnectSuccessDelegate has been successful
}));
FRegistry::Lobby.SetConnectFailedDelegate(AccelByte::Api::Lobby::ConnectError.CreateLambda([]()
{
// Do something if ConnectFailedDelegate has been successful
}));
FRegistry::Lobby.SetConnectionClosedDelegate(AccelByte::Api::Lobby::ConnectionClosed.CreateLambda([]()
{
// Do something if ConnectionClosedDelegate has been successful
}));
AccelBytePlugin.GetLobby().Connect();
AccelBytePlugin.GetLobby().Connected += () =>
{
// Do something if Lobby Connected
};
AccelBytePlugin.GetLobby().Disconnected += error =>
{
// Do something if Lobby Disconnected
Debug.Log($"Lobby Disconnected, Error Code: {(int) error}");
};