Exemplo n.º 1
0
        private bool CreateGroupFromNotification(string gameRefID, string characterID, string login, Hashtable data)
        {
            string sourceGameRefID   = data.Value <string>((int)SPC.GameRefId);
            string sourceCharacterID = data.Value <string>((int)SPC.CharacterId);
            string sourceLogin       = data.Value <string>((int)SPC.Login);

            NebulaCommon.Group.Group group = null;
            if (mCache.TryGetGroupForCharacter(sourceCharacterID, out group))
            {
                if (group.IsLeader(sourceCharacterID))
                {
                    if (AddCharacterToGroup(group, gameRefID, characterID, login, false))
                    {
                        SendGroupUpdate(group.groupID);
                        SetGroupOnPeer(characterID, group.groupID);
                        return(true);
                    }
                }
            }
            else
            {
                var newGroup = new NebulaCommon.Group.Group {
                    groupID = Guid.NewGuid().ToString()
                };
                bool leaderAdded = AddCharacterToGroup(newGroup, sourceGameRefID, sourceCharacterID, sourceLogin, true);
                bool otherAdded  = AddCharacterToGroup(newGroup, gameRefID, characterID, login, false);
                mCache.TryAddGroup(newGroup);

                if (leaderAdded)
                {
                    SetGroupOnPeer(sourceCharacterID, newGroup.groupID);
                }
                if (otherAdded)
                {
                    SetGroupOnPeer(characterID, newGroup.groupID);
                }
                if (leaderAdded && otherAdded)
                {
                    SendGroupUpdate(newGroup.groupID);
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 2
0
        private bool AddCharacterToGroupNotification(string gameRefID, string characterID, string login, Hashtable data)
        {
            string sourceGameRefID   = data.Value <string>((int)SPC.GameRefId);
            string sourceCharacterID = data.Value <string>((int)SPC.CharacterId);
            string sourceLogin       = data.Value <string>((int)SPC.Login);

            NebulaCommon.Group.Group group = null;
            if (mCache.TryGetGroupForCharacter(sourceCharacterID, out group))
            {
                if (group.IsLeader(sourceCharacterID))
                {
                    if (AddCharacterToGroup(group, gameRefID, characterID, login, false))
                    {
                        SendGroupUpdate(group.groupID);
                        SetGroupOnPeer(characterID, group.groupID);
                        return(true);
                    }
                }
            }
            return(false);
        }