//[AuthorizeJwt(GuardianApplicationRole.ZoneServer)] //TODO: Eventually we'll need to auth these zoneservers. public async Task <IActionResult> WorldTeleportCharacter([FromBody][NotNull] ZoneServerWorldTeleportCharacterRequest requestModel, [FromServices][NotNull] ICharacterLocationRepository characterLocationRepository, [FromServices][NotNull] IGameObjectBehaviourDataServiceClient <WorldTeleporterInstanceModel> worldTelporterDataClient, [FromServices][NotNull] IPlayerSpawnPointDataServiceClient playerSpawnDataClient) { if (requestModel == null) { throw new ArgumentNullException(nameof(requestModel)); } if (characterLocationRepository == null) { throw new ArgumentNullException(nameof(characterLocationRepository)); } if (worldTelporterDataClient == null) { throw new ArgumentNullException(nameof(worldTelporterDataClient)); } if (playerSpawnDataClient == null) { throw new ArgumentNullException(nameof(playerSpawnDataClient)); } //TODO: Right now there is no verification of WHO/WHAT is actually teleporting the player. //We need an authorization system with player-owned zone servers. So that we can determine //who is requesting to transfer the session and then verify that a player is even on //that zone server. ProjectVersionStage.AssertBeta(); //We don't await so that we can get rolling on this VERY async multi-part process. //TODO: Handle failure ResponseModel <WorldTeleporterInstanceModel, SceneContentQueryResponseCode> teleporterInstanceResponse = await worldTelporterDataClient.GetBehaviourInstance(requestModel.WorldTeleporterId); //TODO: Handle failure ResponseModel <PlayerSpawnPointInstanceModel, SceneContentQueryResponseCode> pointInstanceResponse = await playerSpawnDataClient.GetSpawnPointInstance(teleporterInstanceResponse.Result.RemoteSpawnPointId); //Remove current location and update the new location. await characterLocationRepository.TryDeleteAsync(requestModel.CharacterGuid.EntityId); await characterLocationRepository.TryCreateAsync(new CharacterLocationModel(requestModel.CharacterGuid.EntityId, pointInstanceResponse.Result.InitialPosition.x, pointInstanceResponse.Result.InitialPosition.y, pointInstanceResponse.Result.InitialPosition.z, pointInstanceResponse.Result.WorldId)); //TODO: Better indicate reason for failure. return(Ok()); }
protected override void OnEventFired(object source, EventArgs args) { UnityAsyncHelper.UnityMainThreadContext.PostAsync(async() => { try { ResponseModel <ObjectEntryCollectionModel <PlayerSpawnPointInstanceModel>, ContentEntryCollectionResponseCode> responseModel = await PlayerSpawnContentDataClient.GetSpawnPointEntriesByWorld(WorldConfiguration.WorldId); //TODO: Handle failure. foreach (var spawnPoint in responseModel.Result.Entries) { if (!spawnPoint.isReserved) { if (Logger.IsInfoEnabled) { Logger.Info($"Found Player Spawn: {spawnPoint.SpawnPointId}"); } SpawnStrategyQueue.Enqueue(spawnPoint); } } //It's possible the creator didn't specify a spawnpoint, so we just use a default if (SpawnStrategyQueue.Count == 0) { if (Logger.IsWarnEnabled) { Logger.Debug($"No spawnPoints found."); } SpawnStrategyQueue.Enqueue(new PlayerSpawnPointInstanceModel(1, Vector3.zero, 0, false, WorldConfiguration.WorldId)); } } catch (Exception e) { if (Logger.IsErrorEnabled) { Logger.Error($"Failed to fully finish query for PlayerSpawnPoint data. Reason: {e.Message}\nStack: {e.StackTrace}"); } } }); }
protected override void OnGuildStatusChanged(GuildStatusChangedEventModel changeArgs) { //TODO: This needs to be authorative ProjectVersionStage.AssertBeta(); //If we're now guildless, we need to actually leave the guild chat channel //if we're in one. if (changeArgs.IsGuildless) { //TODO: Handle leaving guild channel return; } //We have a guild, let's join the guild channel now. UnityAsyncHelper.UnityMainThreadContext.PostAsync(async() => { try { ResponseModel <VivoxChannelJoinResponse, VivoxLoginResponseCode> channelJoinResponse = await VivoxAutheAuthorizationService.JoinGuildChatAsync(); //TODO: Better handle failure. if (!channelJoinResponse.isSuccessful) { if (Logger.IsErrorEnabled) { Logger.Error($"Failed to join Guild world channel. Reason: {channelJoinResponse.ResultCode}"); } return; } if (Logger.IsInfoEnabled) { Logger.Info($"Recieved Vivox Channel URI: {channelJoinResponse.Result.ChannelURI}"); } //TODO: Awaiting the ChatChannelSession may never complete. We should do a timeout. //TODO: We should share these inputs as shared constants. IChannelSession guildChannel = (await ChatChannelSession).GetChannelSession(new ChannelId(channelJoinResponse.Result.ChannelURI)); await guildChannel.ConnectionAsync(false, true, TransmitPolicy.Yes, channelJoinResponse.Result.AuthToken) .ConfigureAwait(true); if (Logger.IsInfoEnabled) { Logger.Info($"Joined Guild Chat"); } //Broadcast that we've joined proximity chat. ChannelJoinEventPublisher.PublishEvent(this, new ChatChannelJoinedEventArgs(ChatChannelType.Guild, new DefaultVivoxTextChannelSubscribableAdapter(guildChannel), new DefaultVivoxChatChannelSenderAdapter(guildChannel))); } catch (Exception e) { if (Logger.IsErrorEnabled) { Logger.Error($"Failed to Initialize Guild chat. Reason: {e.Message}\n\nStack: {e.StackTrace}"); } throw; } }); }
public async Task LoadDataAsync() { //TODO: Handle failure cases. ResponseModel <ObjectEntryCollectionModel <GameObjectInstanceModel>, ContentEntryCollectionResponseCode> entriesByWorld = await DataServiceClient.GetGameObjectEntriesByWorld(WorldConfiguration.WorldId); ResponseModel <ObjectEntryCollectionModel <GameObjectTemplateModel>, ContentEntryCollectionResponseCode> templatesByWorld = await DataServiceClient.GetGameObjectTemplatesByWorld(WorldConfiguration.WorldId); ResponseModel <ObjectEntryCollectionModel <WorldTeleporterInstanceModel>, ContentEntryCollectionResponseCode> teleportersByWorld = await TeleporterDataServiceClient.GetBehaviourEntriesByWorld(WorldConfiguration.WorldId); ResponseModel <ObjectEntryCollectionModel <AvatarPedestalInstanceModel>, ContentEntryCollectionResponseCode> avatarPedestalsByWorld = await AvatarPedestalDataServiceClient.GetBehaviourEntriesByWorld(WorldConfiguration.WorldId); if (entriesByWorld.isSuccessful && templatesByWorld.isSuccessful) { AddGameObjectTemplates(templatesByWorld.Result.Entries); AddGameObjectInstances(entriesByWorld.Result.Entries); //It's possible there were none. if (teleportersByWorld.isSuccessful) { AddGameObjectInstances(teleportersByWorld.Result.Entries); } //It's possible there were none. if (avatarPedestalsByWorld.isSuccessful) { AddGameObjectInstances(avatarPedestalsByWorld.Result.Entries); } } else { if (Logger.IsWarnEnabled) { Logger.Warn($"Didn't properly query GameObject Data. This may not actually be an error. Instance Reason: {entriesByWorld.ResultCode} Template Reason: {templatesByWorld.ResultCode}"); } } }