Dispatched when the connection between the client and the SmartFoxServer 2X instance is interrupted abruptly while the SmartFoxServer 2X HRC system is available in the Zone.

Namespace: Sfs2X.Core
Assembly: SmartFox2X (in SmartFox2X.dll) Version: 1.7.0.0 (1.7.0)

Syntax

C#
public static readonly string CONNECTION_RETRY

Field Value

Type: String

Remarks

The HRC system allows a broken connection to be re-established transparently within a certain amount of time, without losing any of the current application state. For example this allows any player to get back to a game without loosing the match because of a sloppy internet connection.
When this event is dispatched the API enter a "freeze" mode where no new requests can be sent until the reconnection is successfully performed. It is highly recommended to handle this event and freeze the application interface accordingly until the CONNECTION_RESUME event is fired, or the reconnection fails and the user is definitely disconnected and the CONNECTION_LOST event is fired.

No parameters are available for this event object.

Examples

The following example shows how to handle a reconnection
 Copy imageCopy
void SomeMethod() {
    sfs.AddEventListener(SFSEvent.CONNECTION_RETRY, OnConnectionRetry);
    sfs.AddEventListener(SFSEvent.CONNECTION_RESUME, OnConnectionResume);
    sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
}
void OnConnectionRetry(BaseEvent evt) {
    // Freeze your GUI and provide some feedback to the Player
    ...
}
void OnConnectionResume(BaseEvent evt) {
    // Unfreeze the GUI and let the player continue with the game
    ...
}
void OnConnectionLost(BaseEvent evt) {
    Console.WriteLine("Ouch, connection was lost! Reason: " + (string)evt.Params["reason"]);                        // .Net / Unity
    System.Diagnostics.Debug.WriteLine("Ouch, connection was lost! Reason: " + (string)evt.Params["reason"]);       // Windows Universal
}

See Also