Esempio n. 1
0
        private IEnumerator HandleRequestCharactersRoutine(LiteNetLibMessageHandler messageHandler)
        {
            long connectionId = messageHandler.connectionId;
            RequestCharactersMessage message = messageHandler.ReadMessage <RequestCharactersMessage>();

            ResponseCharactersMessage.Error error      = ResponseCharactersMessage.Error.None;
            List <PlayerCharacterData>      characters = null;
            CentralUserPeerInfo             userPeerInfo;

            if (!userPeers.TryGetValue(connectionId, out userPeerInfo))
            {
                error = ResponseCharactersMessage.Error.NotLoggedin;
            }
            else
            {
                ReadCharactersJob job = new ReadCharactersJob(Database, userPeerInfo.userId);
                job.Start();
                yield return(StartCoroutine(job.WaitFor()));

                characters = job.result;
            }
            ResponseCharactersMessage responseMessage = new ResponseCharactersMessage();

            responseMessage.ackId        = message.ackId;
            responseMessage.responseCode = error == ResponseCharactersMessage.Error.None ? AckResponseCode.Success : AckResponseCode.Error;
            responseMessage.error        = error;
            responseMessage.characters   = characters;
            ServerSendPacket(connectionId, DeliveryMethod.ReliableOrdered, MMOMessageTypes.ResponseCharacters, responseMessage);
        }
Esempio n. 2
0
        private async UniTaskVoid HandleRequestCharactersRoutine(LiteNetLibMessageHandler messageHandler)
        {
            long connectionId = messageHandler.connectionId;
            RequestCharactersMessage message = messageHandler.ReadMessage <RequestCharactersMessage>();

            ResponseCharactersMessage.Error error      = ResponseCharactersMessage.Error.None;
            List <PlayerCharacterData>      characters = null;
            CentralUserPeerInfo             userPeerInfo;

            if (!userPeers.TryGetValue(connectionId, out userPeerInfo))
            {
                error = ResponseCharactersMessage.Error.NotLoggedin;
            }
            else
            {
                CharactersResp charactersResp = await DbServiceClient.ReadCharactersAsync(new ReadCharactersReq()
                {
                    UserId = userPeerInfo.userId
                });

                characters = DatabaseServiceUtils.MakeListFromRepeatedByteString <PlayerCharacterData>(charactersResp.List);
            }
            ResponseCharactersMessage responseMessage = new ResponseCharactersMessage();

            responseMessage.ackId        = message.ackId;
            responseMessage.responseCode = error == ResponseCharactersMessage.Error.None ? AckResponseCode.Success : AckResponseCode.Error;
            responseMessage.error        = error;
            responseMessage.characters   = characters;
            ServerSendResponse(connectionId, MMOMessageTypes.ResponseCharacters, responseMessage);
        }
Esempio n. 3
0
        public uint RequestCharacters(AckMessageCallback callback)
        {
            var message = new RequestCharactersMessage();

            return(Client.ClientSendAckPacket(SendOptions.ReliableOrdered, MMOMessageTypes.RequestCharacters, message, callback));
        }
Esempio n. 4
0
        public uint RequestCharacters(AckMessageCallback callback)
        {
            RequestCharactersMessage message = new RequestCharactersMessage();

            return(Client.ClientSendAckPacket(DeliveryMethod.ReliableOrdered, MMOMessageTypes.RequestCharacters, message, callback));
        }
Esempio n. 5
0
        public uint RequestCharacters(AckMessageCallback callback)
        {
            RequestCharactersMessage message = new RequestCharactersMessage();

            return(ClientSendRequest(MMOMessageTypes.RequestCharacters, message, callback));
        }