Skip to main content
Version: 5.11.8

connect-to-notify-server

public void Connect(bool reconnection = true, long reconnectionDelay = 1000, long reconnectionDelayMax = 5000, int reconnectionAttempts = 1000);

Description

Connects to the real-time notification server. You can connect even if it is not activated in BACKND Console, but in this case, you will not receive any notifications.
After connecting, the authentication process starts, and the result will be passed to the OnAuthorize handler.

Unlike the existing BACKND Base methods, you get the returned value at the handler.

Parameters

ValueTypeDescriptionDefault
reconnectionboolWhether to reconnect after disconnection
reconnectionDelaylongThe reconnection delay after disconnection(ms)
reconnectionDelayMaxlongThe maximum reconnection delay after disconnection(ms)
reconnectionAttemptslongThe maximum number of attempts to reconnect

Example

// Define the handler to be called upon connection
Backend.Notification.OnAuthorize = (bool Result, string Reason) => {
Debug.Log("Success/failure of connection to real-time server : " + Result);
Debug.Log("Reason when failed : " + Reason);
};

// Connect to the real-time notification server
Backend.Notification.Connect();

OnAuthorize

public OnNotificationAuthorize OnAuthorize;

Parameters

ValueTypeDescription
ResultboolConnection result(true means success and false means failure)
ReasonstringReason for failure('successed w/ {socket.id}' is printed when successful)

Description

When Connect is called, the authentication process automatically starts, and the result will be passed to the OnAuthorize handler.

Example

Backend.Notification.OnAuthorize = (bool Result, string Reason) => {
Debug.Log("Trying to connect to the real-time notification server!");

//Process after connection
if(Result)
{
Debug.Log("Successfully connected to the real-time notification server!");
}
else
{
Debug.Log("Failed to connect to the real-time notification server : Reason: " + Reason);
}
}

ResponseCase

Success cases

Result(bool)Reason(string)Description
truesuccessed w/ `$socket.id`ErrorCode

Fail cases

Result(bool)Reason(string)Description
falsebad clientAppIdErrorCode
bad accessTokenErrorCode
bad expired accessTokenErrorCode