add log message that says a restart to the api is required to reestablish connection with mmo

This commit is contained in:
Alan Moon 2025-03-18 13:44:01 -07:00
parent c57d3589c0
commit bfc5b6a974

View File

@ -45,12 +45,14 @@ public class MMOClientService : IHostedService
SFSClient.Connect(SFSConfig); SFSClient.Connect(SFSConfig);
SFSClient.AddEventListener(SFSEvent.CONNECTION, OnConnectionEstablished); SFSClient.AddEventListener(SFSEvent.CONNECTION, OnConnectionEstablished);
SFSClient.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
SFSClient.AddEventListener(SFSEvent.LOGIN, OnLogin); SFSClient.AddEventListener(SFSEvent.LOGIN, OnLogin);
// return completed task (SmartFox seems to be completely synchronous) // return completed task (SmartFox seems to be completely synchronous)
return Task.CompletedTask; return Task.CompletedTask;
} }
public Task SetRoomVarForRoom(int roomId, RoomVariable var) public Task SetRoomVarForRoom(int roomId, RoomVariable var)
{ {
if (IsLoggedIn) if (IsLoggedIn)
@ -100,6 +102,12 @@ public class MMOClientService : IHostedService
} }
} }
private void OnConnectionLost(BaseEvent evt)
{
Console.WriteLine($"Connection To The MMO Server Was Lost. Reason - {(string)evt.Params["reason"]}");
Console.WriteLine("MMO Service Currently Not Ready.\nThis Required A Full API Restart For Realtime Communication To Be Reestablished.");
}
private void OnLogin(BaseEvent evt) private void OnLogin(BaseEvent evt)
{ {
CurrentUser = (User)evt.Params["user"]; CurrentUser = (User)evt.Params["user"];