/// <inheritdoc /> public async Task OnGameInitialized() { //TODO: Should we check if it's still connected? await ClientManager.StartHandlingNetworkClient(Client) .ConfigureAwait(true); //it's just scene start, it's probably ok to capture the sync context OnNetworkConnectionEstablished?.Invoke(this, EventArgs.Empty); }
//TODO: We need to handle failure cases, maybe with a window popup and bringing back to the titlescreen. /// <inheritdoc /> public async Task OnGameInitialized() { //When we reach this scene, the pre lobby burst scene //we need to actually connect to the zone/lobby. //it verry well could be a zone. Maybe we were in a party and are reconnecting to it //no matter what though, we need to get information about our //character session and then the zone it should be connecting to //then we can connect. //First we need to know what zone this session should be going to CharacterSessionDataResponse sessionData = await CharacterDataService.GetCharacterSessionData(CharacterDataRepo.CharacterId, AuthTokenRepo.RetrieveWithType()) .ConfigureAwait(true); //TODO: Handle this better if (!sessionData.isSuccessful) { Logger.Error($"Failed to query session data for Character: {CharacterDataRepo.CharacterId}. Cannot connect to instance server."); return; } ResolveServiceEndpointResponse zoneEndpointResponse = await ZoneService.GetServerEndpoint(sessionData.ZoneId); if (!zoneEndpointResponse.isSuccessful) { Logger.Error($"Failed to query endpoint for Zone: {sessionData.ZoneId} which Character: {CharacterDataRepo.CharacterId} is in. Cannot connect to instance server."); return; } //TODO: Don't hardcode gameserver connection details //As soon as we start we should attempt to connect to the login server. bool result = await Client.ConnectAsync(IPAddress.Parse(zoneEndpointResponse.Endpoint.EndpointAddress), zoneEndpointResponse.Endpoint.EndpointPort) .ConfigureAwait(true); if (!result) { throw new InvalidOperationException($"Failed to connect to Server: {zoneEndpointResponse.Endpoint.EndpointAddress} Port: {zoneEndpointResponse.Endpoint.EndpointPort}"); } if (Logger.IsDebugEnabled) { Logger.Debug($"Connected client. isConnected: {Client.isConnected}"); } //Basically we just take the network client and tell the client manager to start dealing with it //since it's connecting the manager should start pumping the messages out of it. await NetworkClientManager.StartHandlingNetworkClient(Client) .ConfigureAwait(true); //We should broadcast that the connection has been established to any interested subscribers OnNetworkConnectionEstablished?.Invoke(this, EventArgs.Empty); }
public async Task OnGameStart() { if (!Client.isConnected) { if (Logger.IsWarnEnabled) { Logger.Warn($"Network Connection is disconnected. Cannot restart handling."); } } else { //TODO: Should we check if it's still connected? await ClientManager.StartHandlingNetworkClient(Client) .ConfigureAwait(true); //it's just scene start, it's probably ok to capture the sync context if (Logger.IsInfoEnabled) { Logger.Warn($"Network Connection restarted. Message handling resumed. Dispatching {nameof(INetworkConnectionEstablishedEventSubscribable)}"); } OnNetworkConnectionEstablished?.Invoke(this, EventArgs.Empty); } }