Client API: C# 1.7.18 in Unity
What happends: OnConnectionLost(BaseEvent e) paramater reason "unknown". If on the Server max idle time for clients reached and the server disconnects the client.
What should happends: paramater reason = idle;
Example code C#
Code: Select all
private void Start()
{
sf = new SmartFox();
sf.ThreadSafeMode = true;
sf.AddEventListener(SFSEvent.CONNECTION, OnConnection);
sf.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
sf.Connect(serverIP, serverPort);
}
private void Update()
{
sf.ProcessEvents();
}
private void OnConnection(BaseEvent e)
{
if ((bool)e.Params["success"])
{
IsConnected = true;
ServerInfoMessage = "Successfully connected";
}
else
{
IsConnected = false;
ServerInfoMessage = "Connection failed";
}
}
private void OnConnectionLost(BaseEvent e)
{
Debug.Log("Connection was lost, Reason: " + (string)e.Params["reason"]);
}