Exemplo n.º 1
0
        protected void HandleUpdateMapUser(LiteNetLibMessageHandler messageHandler)
        {
            long connectionId = messageHandler.connectionId;
            UpdateUserCharacterMessage message = messageHandler.ReadMessage <UpdateUserCharacterMessage>();

            if (mapUserIds.ContainsKey(connectionId))
            {
                switch (message.type)
                {
                case UpdateUserCharacterMessage.UpdateType.Add:
                    if (!mapUserIds[connectionId].Contains(message.UserId))
                    {
                        mapUserIds[connectionId].Add(message.UserId);
                        if (LogInfo)
                        {
                            Debug.Log("[Central] Add map user: "******" by " + connectionId);
                        }
                    }
                    break;

                case UpdateUserCharacterMessage.UpdateType.Remove:
                    mapUserIds[connectionId].Remove(message.UserId);
                    if (LogInfo)
                    {
                        Debug.Log("[Central] Remove map user: "******" by " + connectionId);
                    }
                    break;
                }
            }
        }
        private void UpdateMapUser(long connectionId, UpdateUserCharacterMessage.UpdateType updateType, UserCharacterData userData)
        {
            UpdateUserCharacterMessage updateMapUserMessage = new UpdateUserCharacterMessage();

            updateMapUserMessage.type = updateType;
            updateMapUserMessage.data = userData;
            ServerSendPacket(connectionId, DeliveryMethod.ReliableOrdered, MMOMessageTypes.UpdateMapUser, updateMapUserMessage);
        }
        private void UpdateMapUser(TransportHandler transportHandler, UpdateUserCharacterMessage.UpdateType updateType, UserCharacterData userData)
        {
            var updateMapUserMessage = new UpdateUserCharacterMessage();

            updateMapUserMessage.type = updateType;
            updateMapUserMessage.data = userData;
            transportHandler.ClientSendPacket(SendOptions.ReliableOrdered, MMOMessageTypes.UpdateMapUser, updateMapUserMessage.Serialize);
        }
Exemplo n.º 4
0
        private void UpdateMapUser(long connectionId, UpdateUserCharacterMessage.UpdateType updateType, SocialCharacterData userData)
        {
            UpdateUserCharacterMessage message = new UpdateUserCharacterMessage();

            message.type      = updateType;
            message.character = userData;
            SendPacket(connectionId, 0, DeliveryMethod.ReliableOrdered, MMOMessageTypes.UpdateMapUser, (writer) => writer.PutValue(message));
        }
        private void UpdateMapUser(LiteNetLibClient transportHandler, UpdateUserCharacterMessage.UpdateType updateType, SocialCharacterData userData)
        {
#if UNITY_STANDALONE && !CLIENT_BUILD
            UpdateUserCharacterMessage updateMapUserMessage = new UpdateUserCharacterMessage();
            updateMapUserMessage.type = updateType;
            updateMapUserMessage.data = userData;
            transportHandler.SendPacket(0, DeliveryMethod.ReliableOrdered, MMOMessageTypes.UpdateMapUser, updateMapUserMessage.Serialize);
#endif
        }
        private void HandleUpdateMapUserAtClient(LiteNetLibMessageHandler messageHandler)
        {
            UpdateUserCharacterMessage message = messageHandler.ReadMessage <UpdateUserCharacterMessage>();

            if (mapNetworkManager != null)
            {
                mapNetworkManager.OnUpdateMapUser(message);
            }
        }
        private void HandleUpdateMapUserAtServer(LiteNetLibMessageHandler messageHandler)
        {
            long connectionId = messageHandler.connectionId;
            UpdateUserCharacterMessage message = messageHandler.ReadMessage <UpdateUserCharacterMessage>();

            if (mapServerConnectionIds.Contains(connectionId))
            {
                UserCharacterData userData;
                switch (message.type)
                {
                case UpdateUserCharacterMessage.UpdateType.Add:
                    if (!mapUsersById.ContainsKey(message.data.id))
                    {
                        mapUsersById[message.data.id] = message.data;
                        connectionIdsByCharacterId[message.data.id] = connectionId;
                        connectionIdsByCharacterName[message.data.characterName] = connectionId;
                        UpdateMapUser(UpdateUserCharacterMessage.UpdateType.Add, message.data, connectionId);
                        if (LogInfo)
                        {
                            Debug.Log("[Chat] Add map user: "******" by " + connectionId);
                        }
                    }
                    break;

                case UpdateUserCharacterMessage.UpdateType.Remove:
                    if (mapUsersById.TryGetValue(message.data.id, out userData))
                    {
                        mapUsersById.Remove(userData.id);
                        connectionIdsByCharacterId.Remove(userData.id);
                        connectionIdsByCharacterName.Remove(userData.characterName);
                        UpdateMapUser(UpdateUserCharacterMessage.UpdateType.Remove, userData, connectionId);
                        if (LogInfo)
                        {
                            Debug.Log("[Chat] Remove map user: "******" by " + connectionId);
                        }
                    }
                    break;

                case UpdateUserCharacterMessage.UpdateType.Online:
                    if (mapUsersById.ContainsKey(message.data.id))
                    {
                        mapUsersById[message.data.id] = message.data;
                        UpdateMapUser(UpdateUserCharacterMessage.UpdateType.Online, message.data, connectionId);
                        if (LogInfo)
                        {
                            Debug.Log("[Chat] Update map user: "******" by " + connectionId);
                        }
                    }
                    break;
                }
            }
        }
        public void OnUpdateMapUser(UpdateUserCharacterMessage message)
        {
#if UNITY_STANDALONE && !CLIENT_BUILD
            int       socialId;
            PartyData party;
            GuildData guild;
            switch (message.type)
            {
            case UpdateUserCharacterMessage.UpdateType.Add:
                if (!usersById.ContainsKey(message.data.id))
                {
                    usersById.TryAdd(message.data.id, message.data);
                }
                break;

            case UpdateUserCharacterMessage.UpdateType.Remove:
                usersById.TryRemove(message.data.id, out _);
                break;

            case UpdateUserCharacterMessage.UpdateType.Online:
                if (usersById.ContainsKey(message.data.id))
                {
                    ServerCharacterHandlers.MarkOnlineCharacter(message.data.id);
                    socialId = message.data.partyId;
                    if (socialId > 0 && ServerPartyHandlers.TryGetParty(socialId, out party))
                    {
                        party.UpdateMember(message.data);
                        ServerPartyHandlers.SetParty(socialId, party);
                    }
                    socialId = message.data.guildId;
                    if (socialId > 0 && ServerGuildHandlers.TryGetGuild(socialId, out guild))
                    {
                        guild.UpdateMember(message.data);
                        ServerGuildHandlers.SetGuild(socialId, guild);
                    }
                    usersById[message.data.id] = message.data;
                }
                break;
            }
#endif
        }
        public void OnUpdateMapUser(UpdateUserCharacterMessage message)
        {
            int       socialId;
            PartyData party;
            GuildData guild;

            switch (message.type)
            {
            case UpdateUserCharacterMessage.UpdateType.Add:
                if (!usersById.ContainsKey(message.CharacterId))
                {
                    usersById.Add(message.CharacterId, message.data);
                }
                break;

            case UpdateUserCharacterMessage.UpdateType.Remove:
                usersById.Remove(message.CharacterId);
                break;

            case UpdateUserCharacterMessage.UpdateType.Online:
                if (usersById.ContainsKey(message.CharacterId))
                {
                    socialId = message.data.partyId;
                    if (socialId > 0 && parties.TryGetValue(socialId, out party))
                    {
                        party.UpdateMember(message.data.ToSocialCharacterData());
                        party.NotifyOnlineMember(message.CharacterId);
                        parties[socialId] = party;
                    }
                    socialId = message.data.guildId;
                    if (socialId > 0 && guilds.TryGetValue(socialId, out guild))
                    {
                        guild.UpdateMember(message.data.ToSocialCharacterData());
                        guild.NotifyOnlineMember(message.CharacterId);
                        guilds[socialId] = guild;
                    }
                    usersById[message.CharacterId] = message.data;
                }
                break;
            }
        }
Exemplo n.º 10
0
        private void HandleUpdateMapUserAtServer(MessageHandlerData messageHandler)
        {
            long connectionId = messageHandler.ConnectionId;
            UpdateUserCharacterMessage message = messageHandler.ReadMessage <UpdateUserCharacterMessage>();

            if (mapServerConnectionIds.Contains(connectionId))
            {
                SocialCharacterData userData;
                switch (message.type)
                {
                case UpdateUserCharacterMessage.UpdateType.Add:
                    if (!mapUsersById.ContainsKey(message.data.id))
                    {
                        mapUsersById[message.data.id] = message.data;
                        connectionIdsByCharacterId[message.data.id] = connectionId;
                        connectionIdsByCharacterName[message.data.characterName] = connectionId;
                        UpdateMapUser(UpdateUserCharacterMessage.UpdateType.Add, message.data, connectionId);
                    }
                    break;

                case UpdateUserCharacterMessage.UpdateType.Remove:
                    if (mapUsersById.TryGetValue(message.data.id, out userData))
                    {
                        mapUsersById.Remove(userData.id);
                        connectionIdsByCharacterId.Remove(userData.id);
                        connectionIdsByCharacterName.Remove(userData.characterName);
                        UpdateMapUser(UpdateUserCharacterMessage.UpdateType.Remove, userData, connectionId);
                    }
                    break;

                case UpdateUserCharacterMessage.UpdateType.Online:
                    if (mapUsersById.ContainsKey(message.data.id))
                    {
                        mapUsersById[message.data.id] = message.data;
                        UpdateMapUser(UpdateUserCharacterMessage.UpdateType.Online, message.data, connectionId);
                    }
                    break;
                }
            }
        }