Example #1
0
 /// <inheritdoc />
 protected override async void OnEventFired(object source, EventArgs args)
 {
     //TODO: Check result
     //We don't need to be on the main thread to send a session claim request.
     await SendService.SendMessage(new ClientSessionClaimRequestPayload(AuthTokenRepository.RetrieveWithType(), CharacterDataRepository.CharacterId))
     .ConfigureAwait(false);
 }
Example #2
0
        protected override void OnEventFired(object source, EventArgs args)
        {
            //Once connection to the instance server is established
            //we must attempt to claim out session on to actually fully enter.

            //We send time sync first since we need to have a good grasp of the current network time before
            //we even spawn into the world and start recieveing the world states.
            SendService.SendMessageImmediately(new ServerTimeSyncronizationRequestPayload(DateTime.UtcNow.Ticks))
            .ConfigureAwaitFalse();

            //TODO: When it comes to community servers, we should not expose the sensitive JWT to them. We need a better way to deal with auth against untrusted instance servers
            SendService.SendMessage(new ClientSessionClaimRequestPayload(AuthTokenRepository.RetrieveWithType(), CharacterDataRepository.CharacterId));
        }
Example #3
0
        //TODO: Race condition here because it's possible the subsciber hasn't subscribed just yet.
        /// <inheritdoc />
        public async Task OnGameInitialized()
        {
            CharacterListResponse listResponse = await CharacterQueryable.GetCharacters(AuthTokenRepository.RetrieveWithType())
                                                 .ConfigureAwait(true);

            if (!listResponse.isSuccessful || listResponse.CharacterIds.Count == 0)
            {
                if (Logger.IsErrorEnabled)
                {
                    Logger.Error($"Failed to query character list. Recieved ResultCode: {listResponse.ResultCode}");
                }

                //We don't have character creation... Soooo, nothing we can do right now.
                return;
            }

            //TODO: Should we make this API spit out network guids?
            foreach (var characterId in listResponse.CharacterIds)
            {
                NetworkEntityGuid entityGuid = new NetworkEntityGuidBuilder()
                                               .WithType(EntityType.Player)
                                               .WithId(characterId)
                                               .Build();

                OnCharacterSelectionEntryChanged?.Invoke(this, new CharacterSelectionEntryDataChangeEventArgs(entityGuid));
            }
        }
        protected override void OnEventFired(object source, EventArgs args)
        {
            //Once connection to the instance server is established
            //we must attempt to claim out session on to actually fully enter.
            EventQueueable.Enqueue(async() =>
            {
                try
                {
                    CharacterListResponse listResponse = await CharacterService.GetCharacters();

                    await CharacterService.TryEnterSession(listResponse.CharacterIds.First());

                    CharacterDataRepository.UpdateCharacterId(listResponse.CharacterIds.First());

                    //TODO: When it comes to community servers, we should not expose the sensitive JWT to them. We need a better way to deal with auth against untrusted instance servers
                    await SendService.SendMessage(new ClientSessionClaimRequestPayload(AuthTokenRepository.RetrieveWithType(), listResponse.CharacterIds.First()));
                }
                catch (Exception e)
                {
                    if (Logger.IsErrorEnabled)
                    {
                        Logger.Error($"Failed to authenticate to instance server as character. Reason: {e.ToString()}");
                    }

                    throw;
                }
            });
        }