Exemple #1
0
        public async Task EnterScene(IYield yield)
        {
            var responseParameters = await ServerPeerHandler.SendOperation <EmptyParameters, EnterSceneResponseParameters>
                                         (yield, (byte)GameOperations.EnterScene, new EmptyParameters(), MessageSendOptions.DefaultReliable());

            SceneEntered?.Invoke(responseParameters);
        }
Exemple #2
0
        public async Task <GameServersProviderResponseParameters> ProvideGameServers(IYield yield)
        {
            var responseParameters = await ServerPeerHandler.SendOperation <EmptyParameters, GameServersProviderResponseParameters>
                                         (yield, (byte)GameServerProviderOperations.ProvideGameServers, new EmptyParameters(), MessageSendOptions.DefaultReliable());

            return(responseParameters);
        }
Exemple #3
0
        public async Task <ValidateCharacterResponseParameters> ValidateCharacter(IYield yield, ValidateCharacterRequestParameters parameters)
        {
            var responseParameters = await ServerPeerHandler.SendOperation <ValidateCharacterRequestParameters, ValidateCharacterResponseParameters>
                                         (yield, (byte)CharacterOperations.ValidateCharacter, parameters, MessageSendOptions.DefaultReliable());

            if (responseParameters.Status == CharacterValidationStatus.Ok)
            {
                ServiceContainer.GameService.SetPeerLogic <GameScenePeerLogic, GameOperations, GameEvents>();
            }
            return(responseParameters);
        }
        public async Task <AuthenticateResponseParameters> Authenticate(IYield yield, AuthenticateRequestParameters parameters)
        {
            var responseParameters = await ServerPeerHandler.SendOperation <AuthenticateRequestParameters, AuthenticateResponseParameters>
                                         (yield, (byte)LoginOperations.Authenticate, parameters, MessageSendOptions.DefaultReliable());

            if (responseParameters.HasAccessToken)
            {
                AccessTokenProvider.AccessToken = responseParameters.AccessToken;
            }
            return(new AuthenticateResponseParameters(responseParameters.Status));
        }
Exemple #5
0
 private void RemoveEventsHandlers()
 {
     ServerPeerHandler.RemoveEventHandler((byte)GameEvents.SceneObjectAdded);
     ServerPeerHandler.RemoveEventHandler((byte)GameEvents.SceneObjectRemoved);
     ServerPeerHandler.RemoveEventHandler((byte)GameEvents.SceneObjectsAdded);
     ServerPeerHandler.RemoveEventHandler((byte)GameEvents.SceneObjectsRemoved);
     ServerPeerHandler.RemoveEventHandler((byte)GameEvents.PositionChanged);
     ServerPeerHandler.RemoveEventHandler((byte)GameEvents.PlayerStateChanged);
     ServerPeerHandler.RemoveEventHandler((byte)GameEvents.PlayerAttacked);
     ServerPeerHandler.RemoveEventHandler((byte)GameEvents.CharacterAdded);
     ServerPeerHandler.RemoveEventHandler((byte)GameEvents.CharactersAdded);
     ServerPeerHandler.RemoveEventHandler((byte)GameEvents.BubbleMessage);
 }
Exemple #6
0
        public void SetPeerLogic <T, TOperationCode, TEventCode>()
            where T : IPeerLogicBase, new()
            where TOperationCode : IComparable, IFormattable, IConvertible
            where TEventCode : IComparable, IFormattable, IConvertible
        {
            peerLogicBase?.Dispose();
            serverPeerHandler?.Dispose();

            var peerHandler = new ServerPeerHandler <TOperationCode, TEventCode>();

            peerHandler.Initialize(ServiceConnectionHandler.ServerPeer ?? new PhotonPeer());
            serverPeerHandler = peerHandler;

            peerLogicBase = new T();
            peerLogicBase.Awake(serverPeerHandler);
        }
Exemple #7
0
 public async Task <RemoveCharacterResponseParameters> RemoveCharacter(IYield yield, RemoveCharacterRequestParameters parameters)
 {
     return(await ServerPeerHandler.SendOperation <RemoveCharacterRequestParameters, RemoveCharacterResponseParameters>
                (yield, (byte)CharacterOperations.RemoveCharacter, parameters, MessageSendOptions.DefaultReliable()));
 }
Exemple #8
0
 public async Task <GetCharactersResponseParameters> GetCharacters(IYield yield)
 {
     return(await ServerPeerHandler.SendOperation <EmptyParameters, GetCharactersResponseParameters>
                (yield, (byte)CharacterOperations.GetCharacters, new EmptyParameters(), MessageSendOptions.DefaultReliable()));
 }
Exemple #9
0
 public void UpdatePosition(UpdatePositionRequestParameters parameters) =>
 ServerPeerHandler.SendOperation((byte)GameOperations.PositionChanged, parameters, MessageSendOptions.DefaultUnreliable((byte)GameDataChannels.Position));
Exemple #10
0
 public async Task <ChangeSceneResponseParameters> ChangeScene(IYield yield, ChangeSceneRequestParameters parameters)
 {
     return(await ServerPeerHandler.SendOperation <ChangeSceneRequestParameters, ChangeSceneResponseParameters>
                (yield, (byte)GameOperations.ChangeScene, parameters, MessageSendOptions.DefaultReliable()));
 }
Exemple #11
0
 public void UpdatePlayerState(UpdatePlayerStateRequestParameters parameters) =>
 ServerPeerHandler.SendOperation((byte)GameOperations.PlayerStateChanged, parameters, MessageSendOptions.DefaultUnreliable((byte)GameDataChannels.Animations));
 public void SendChatMessage(ChatMessageRequestParameters parameters)
 {
     ServerPeerHandler.SendOperation((byte)ChatOperations.ChatMessage, parameters, MessageSendOptions.DefaultReliable());
 }
        protected override void OnDestroy()
        {
            base.OnDestroy();

            ServerPeerHandler.RemoveEventHandler((byte)ChatEvents.ChatMessage);
        }
        protected override void OnAwake()
        {
            base.OnAwake();

            ServerPeerHandler.SetEventHandler((byte)ChatEvents.ChatMessage, ChatMessageReceived);
        }
 public async Task <AuthorizeResponseParameters> Authorize(IYield yield, AuthorizeRequestParameters parameters)
 {
     return(await ServerPeerHandler.SendOperation <AuthorizeRequestParameters, AuthorizeResponseParameters>
                (yield, (byte)AuthorizationOperations.Authorize, parameters, MessageSendOptions.DefaultReliable()));
 }