public void OnUpdateParty(UpdatePartyMessage message)
        {
            BasePlayerCharacterEntity playerCharacterEntity;
            PartyData party;

            if (ServerPartyHandlers.TryGetParty(message.id, out party))
            {
                switch (message.type)
                {
                case UpdatePartyMessage.UpdateType.ChangeLeader:
                    party.SetLeader(message.characterId);
                    ServerPartyHandlers.SetParty(message.id, party);
                    ServerGameMessageHandlers.SendSetPartyLeaderToMembers(party);
                    break;

                case UpdatePartyMessage.UpdateType.Setting:
                    party.Setting(message.shareExp, message.shareItem);
                    ServerPartyHandlers.SetParty(message.id, party);
                    ServerGameMessageHandlers.SendSetPartySettingToMembers(party);
                    break;

                case UpdatePartyMessage.UpdateType.Terminate:
                    foreach (string memberId in party.GetMemberIds())
                    {
                        if (ServerUserHandlers.TryGetPlayerCharacterById(memberId, out playerCharacterEntity))
                        {
                            playerCharacterEntity.ClearParty();
                            ServerGameMessageHandlers.SendClearPartyData(playerCharacterEntity.ConnectionId, message.id);
                        }
                    }
                    ServerPartyHandlers.RemoveParty(message.id);
                    break;
                }
            }
        }
        public void OnUpdateGuildMember(UpdateSocialMemberMessage message)
        {
            GuildData guild;
            BasePlayerCharacterEntity playerCharacterEntity;

            if (ServerGuildHandlers.TryGetGuild(message.id, out guild) && guild.UpdateSocialGroupMember(message))
            {
                switch (message.type)
                {
                case UpdateSocialMemberMessage.UpdateType.Add:
                    if (ServerUserHandlers.TryGetPlayerCharacterById(message.data.id, out playerCharacterEntity))
                    {
                        playerCharacterEntity.GuildId   = message.id;
                        playerCharacterEntity.GuildName = guild.guildName;
                        playerCharacterEntity.GuildRole = guild.GetMemberRole(playerCharacterEntity.Id);
                        ServerGameMessageHandlers.SendSetGuildData(playerCharacterEntity.ConnectionId, guild);
                        ServerGameMessageHandlers.SendAddGuildMembersToOne(playerCharacterEntity.ConnectionId, guild);
                    }
                    ServerGameMessageHandlers.SendAddGuildMemberToMembers(guild, message.data.id, message.data.characterName, message.data.dataId, message.data.level);
                    break;

                case UpdateSocialMemberMessage.UpdateType.Remove:
                    if (ServerUserHandlers.TryGetPlayerCharacterById(message.data.id, out playerCharacterEntity))
                    {
                        playerCharacterEntity.ClearGuild();
                        ServerGameMessageHandlers.SendClearGuildData(playerCharacterEntity.ConnectionId, message.id);
                    }
                    ServerGameMessageHandlers.SendRemoveGuildMemberToMembers(guild, message.data.id);
                    break;
                }
            }
        }
        public void OnUpdatePartyMember(UpdateSocialMemberMessage message)
        {
            PartyData party;
            BasePlayerCharacterEntity playerCharacterEntity;

            if (ServerPartyHandlers.TryGetParty(message.id, out party) && party.UpdateSocialGroupMember(message))
            {
                switch (message.type)
                {
                case UpdateSocialMemberMessage.UpdateType.Add:
                    if (ServerUserHandlers.TryGetPlayerCharacterById(message.data.id, out playerCharacterEntity))
                    {
                        playerCharacterEntity.PartyId = message.id;
                        ServerGameMessageHandlers.SendSetPartyData(playerCharacterEntity.ConnectionId, party);
                        ServerGameMessageHandlers.SendAddPartyMembersToOne(playerCharacterEntity.ConnectionId, party);
                    }
                    ServerGameMessageHandlers.SendAddPartyMemberToMembers(party, message.data.id, message.data.characterName, message.data.dataId, message.data.level);
                    break;

                case UpdateSocialMemberMessage.UpdateType.Remove:
                    if (ServerUserHandlers.TryGetPlayerCharacterById(message.data.id, out playerCharacterEntity))
                    {
                        playerCharacterEntity.ClearParty();
                        ServerGameMessageHandlers.SendClearPartyData(playerCharacterEntity.ConnectionId, message.id);
                    }
                    ServerGameMessageHandlers.SendRemovePartyMemberToMembers(party, message.data.id);
                    break;
                }
            }
        }
        public void OnUpdateGuild(UpdateGuildMessage message)
        {
            BasePlayerCharacterEntity playerCharacterEntity;
            GuildData guild;

            if (ServerGuildHandlers.TryGetGuild(message.id, out guild))
            {
                switch (message.type)
                {
                case UpdateGuildMessage.UpdateType.ChangeLeader:
                    guild.SetLeader(message.characterId);
                    ServerGuildHandlers.SetGuild(message.id, guild);
                    if (ServerUserHandlers.TryGetPlayerCharacterById(message.characterId, out playerCharacterEntity))
                    {
                        playerCharacterEntity.GuildRole = guild.GetMemberRole(playerCharacterEntity.Id);
                    }
                    ServerGameMessageHandlers.SendSetGuildLeaderToMembers(guild);
                    break;

                case UpdateGuildMessage.UpdateType.SetGuildMessage:
                    guild.guildMessage = message.guildMessage;
                    ServerGuildHandlers.SetGuild(message.id, guild);
                    ServerGameMessageHandlers.SendSetGuildMessageToMembers(guild);
                    break;

                case UpdateGuildMessage.UpdateType.SetGuildRole:
                    guild.SetRole(message.guildRole, message.roleName, message.canInvite, message.canKick, message.shareExpPercentage);
                    ServerGuildHandlers.SetGuild(message.id, guild);
                    foreach (string memberId in guild.GetMemberIds())
                    {
                        if (ServerUserHandlers.TryGetPlayerCharacterById(memberId, out playerCharacterEntity))
                        {
                            playerCharacterEntity.GuildRole = guild.GetMemberRole(playerCharacterEntity.Id);
                        }
                    }
                    ServerGameMessageHandlers.SendSetGuildRoleToMembers(guild, message.guildRole, message.roleName, message.canInvite, message.canKick, message.shareExpPercentage);
                    break;

                case UpdateGuildMessage.UpdateType.SetGuildMemberRole:
                    guild.SetMemberRole(message.characterId, message.guildRole);
                    ServerGuildHandlers.SetGuild(message.id, guild);
                    if (ServerUserHandlers.TryGetPlayerCharacterById(message.characterId, out playerCharacterEntity))
                    {
                        playerCharacterEntity.GuildRole = guild.GetMemberRole(playerCharacterEntity.Id);
                    }
                    ServerGameMessageHandlers.SendSetGuildMemberRoleToMembers(guild, message.characterId, message.guildRole);
                    break;

                case UpdateGuildMessage.UpdateType.SetSkillLevel:
                    guild.SetSkillLevel(message.dataId, message.level);
                    ServerGuildHandlers.SetGuild(message.id, guild);
                    ServerGameMessageHandlers.SendSetGuildSkillLevelToMembers(guild, message.dataId);
                    break;

                case UpdateGuildMessage.UpdateType.SetGold:
                    guild.gold = message.gold;
                    ServerGuildHandlers.SetGuild(message.id, guild);
                    ServerGameMessageHandlers.SendSetGuildGoldToMembers(guild);
                    break;

                case UpdateGuildMessage.UpdateType.LevelExpSkillPoint:
                    guild.level      = message.level;
                    guild.exp        = message.exp;
                    guild.skillPoint = message.skillPoint;
                    ServerGuildHandlers.SetGuild(message.id, guild);
                    ServerGameMessageHandlers.SendSetGuildLevelExpSkillPointToMembers(guild);
                    break;

                case UpdateGuildMessage.UpdateType.Terminate:
                    foreach (string memberId in guild.GetMemberIds())
                    {
                        if (ServerUserHandlers.TryGetPlayerCharacterById(memberId, out playerCharacterEntity))
                        {
                            playerCharacterEntity.ClearGuild();
                            ServerGameMessageHandlers.SendClearGuildData(playerCharacterEntity.ConnectionId, message.id);
                        }
                    }
                    ServerGuildHandlers.RemoveGuild(message.id);
                    break;
                }
            }
        }