Exemple #1
0
        private void MuteUser(UUID sessionid, IEventQueueService eq, UUID AgentID, ChatSessionMember thismember,
                              bool forward)
        {
            ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock block =
                new ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock
            {
                AgentID      = thismember.AvatarKey,
                CanVoiceChat = thismember.CanVoiceChat,
                IsModerator  = thismember.IsModerator,
                MuteText     = thismember.MuteText,
                MuteVoice    = thismember.MuteVoice,
                Transition   = "ENTER"
            };

            // Send an update to the affected user
            IClientAPI affectedUser = GetActiveClient(thismember.AvatarKey);

            if (affectedUser != null)
            {
                eq.ChatterBoxSessionAgentListUpdates(sessionid, new[] { block }, AgentID, "ENTER",
                                                     affectedUser.Scene.RegionInfo.RegionHandle);
            }
            else if (forward)
            {
                SendMutedUserIM(thismember, sessionid);
            }
        }
Exemple #2
0
        public void DropMemberFromSession(UUID agentID, GridInstantMessage im)
        {
            if (m_doRemoteOnly)
            {
                DoRemoteCallPost(true, "InstantMessageServerURI", agentID, im);
                return;
            }

            ChatSession session;

            chatSessions.TryGetValue(im.SessionID, out session);
            if (session == null)
            {
                return;
            }

            ChatSessionMember member = null;

            foreach (ChatSessionMember testmember in
                     session.Members.Where(testmember => testmember.AvatarKey == im.FromAgentID))
            {
                member = testmember;
            }

            if (member == null)
            {
                return;
            }

            member.HasBeenAdded     = false;
            member.RequestedRemoval = true;

            if (session.Members.Count(mem => mem.HasBeenAdded) == 0)  //If a member hasn't been added, kill this anyway
            {
                chatSessions.Remove(session.SessionID);
                return;
            }

            ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock block =
                new ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock {
                AgentID      = member.AvatarKey,
                CanVoiceChat = member.CanVoiceChat,
                IsModerator  = member.IsModerator,
                MuteText     = member.MuteText,
                MuteVoice    = member.MuteVoice,
                Transition   = "LEAVE"
            };
            foreach (ChatSessionMember sessionMember in session.Members)
            {
                if (sessionMember.HasBeenAdded) //Only send to those in the group
                {
                    UUID regionID = findRegionID(sessionMember.AvatarKey);
                    if (regionID != UUID.Zero)
                    {
                        m_eventQueueService.ChatterBoxSessionAgentListUpdates(
                            session.SessionID, new [] { block }, sessionMember.AvatarKey, "LEAVE", regionID);
                    }
                }
            }
        }
Exemple #3
0
        /// <summary>
        ///   Remove the member from this session
        /// </summary>
        /// <param name = "client"></param>
        /// <param name = "im"></param>
        public void DropMemberFromSession(IClientAPI client, GridInstantMessage im)
        {
            ChatSession session;

            ChatSessions.TryGetValue(im.imSessionID, out session);
            if (session == null)
            {
                return;
            }
            ChatSessionMember member = new ChatSessionMember {
                AvatarKey = UUID.Zero
            };

#if (!ISWIN)
            foreach (ChatSessionMember testmember in session.Members)
            {
                if (testmember.AvatarKey == im.fromAgentID)
                {
                    member = testmember;
                }
            }
#else
            foreach (ChatSessionMember testmember in session.Members.Where(testmember => testmember.AvatarKey == im.fromAgentID))
            {
                member = testmember;
            }
#endif

            if (member.AvatarKey != UUID.Zero)
            {
                session.Members.Remove(member);
            }

            if (session.Members.Count == 0)
            {
                ChatSessions.Remove(session.SessionID);
                return;
            }

            ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock block =
                new ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock
            {
                AgentID      = member.AvatarKey,
                CanVoiceChat = member.CanVoiceChat,
                IsModerator  = member.IsModerator,
                MuteText     = member.MuteText,
                MuteVoice    = member.MuteVoice,
                Transition   = "LEAVE"
            };
            IEventQueueService eq = client.Scene.RequestModuleInterface <IEventQueueService>();
            foreach (ChatSessionMember sessionMember in session.Members)
            {
                eq.ChatterBoxSessionAgentListUpdates(session.SessionID, new[] { block }, sessionMember.AvatarKey, "LEAVE",
                                                     findScene(sessionMember.AvatarKey).RegionInfo.RegionHandle);
            }
        }
Exemple #4
0
        public void CreateGroupChat(UUID agentID, GridInstantMessage im)
        {
            if (m_doRemoteOnly)
            {
                DoRemoteCallPost(true, "InstantMessageServerURI", agentID, im);
                return;
            }

            UUID groupSessionID = im.SessionID;

            GroupRecord groupInfo = m_groupData.GetGroupRecord(agentID, groupSessionID, null);

            if (groupInfo != null)
            {
                if (!GroupPermissionCheck(agentID, groupSessionID, GroupPowers.JoinChat))
                {
                    return;     // They have to be able to join to create a group chat
                }
                // Create the session.
                if (!SessionExists(groupSessionID))
                {
                    CreateSession(new ChatSession {
                        Members   = new List <ChatSessionMember> (),
                        SessionID = groupSessionID,
                        Name      = groupInfo.GroupName
                    });
                    AddMemberToGroup(new ChatSessionMember {
                        AvatarKey    = agentID,
                        CanVoiceChat = false,
                        IsModerator  = GroupPermissionCheck(agentID, groupSessionID, GroupPowers.ModerateChat),
                        MuteText     = false,
                        MuteVoice    = false,
                        HasBeenAdded = true
                    }, groupSessionID);

                    foreach (
                        GroupMembersData gmd in
                        m_groupData.GetGroupMembers(agentID, groupSessionID)
                        .Where(gmd => gmd.AgentID != agentID)
                        .Where(gmd =>
                               (gmd.AgentPowers & (ulong)GroupPowers.JoinChat) == (ulong)GroupPowers.JoinChat))
                    {
                        AddMemberToGroup(new ChatSessionMember {
                            AvatarKey    = gmd.AgentID,
                            CanVoiceChat = false,
                            IsModerator  = GroupPermissionCheck(gmd.AgentID, groupSessionID, GroupPowers.ModerateChat),
                            MuteText     = false,
                            MuteVoice    = false,
                            HasBeenAdded = false
                        }, groupSessionID);
                    }
                    // Tell us that it was made successfully
                    m_eventQueueService.ChatterBoxSessionStartReply(groupInfo.GroupName, groupSessionID,
                                                                    agentID, findRegionID(agentID));
                }
                else
                {
                    ChatSession thisSession = GetSession(groupSessionID);
                    // A session already exists
                    // Add us
                    AddMemberToGroup(new ChatSessionMember {
                        AvatarKey    = agentID,
                        CanVoiceChat = false,
                        IsModerator  = GroupPermissionCheck(agentID, groupSessionID, GroupPowers.ModerateChat),
                        MuteText     = false,
                        MuteVoice    = false,
                        HasBeenAdded = true
                    }, groupSessionID);

                    // Tell us that we entered successfully
                    m_eventQueueService.ChatterBoxSessionStartReply(groupInfo.GroupName, groupSessionID,
                                                                    agentID, findRegionID(agentID));

                    var usAgents    = new List <ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock> ();
                    var notUsAgents = new List <ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock> ();

                    foreach (ChatSessionMember sessionMember in thisSession.Members)
                    {
                        ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock block =
                            new ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock {
                            AgentID      = sessionMember.AvatarKey,
                            CanVoiceChat = sessionMember.CanVoiceChat,
                            IsModerator  = sessionMember.IsModerator,
                            MuteText     = sessionMember.MuteText,
                            MuteVoice    = sessionMember.MuteVoice,
                            Transition   = "ENTER"
                        };
                        if (agentID == sessionMember.AvatarKey)
                        {
                            usAgents.Add(block);
                        }
                        if (sessionMember.HasBeenAdded)
                        {
                            // Don't add not joined yet agents. They don't want to be here.
                            notUsAgents.Add(block);
                        }
                    }
                    foreach (ChatSessionMember member in thisSession.Members)
                    {
                        if (member.HasBeenAdded)    // Only send to those in the group
                        {
                            UUID regionID = findRegionID(member.AvatarKey);
                            if (regionID != UUID.Zero)
                            {
                                if (member.AvatarKey == agentID)
                                {
                                    // Tell 'us' about all the other agents in the group
                                    m_eventQueueService.ChatterBoxSessionAgentListUpdates(
                                        groupSessionID, notUsAgents.ToArray(), member.AvatarKey, "ENTER", regionID);
                                }
                                else
                                {
                                    // Tell 'other' agents about the new agent ('us')
                                    m_eventQueueService.ChatterBoxSessionAgentListUpdates(
                                        groupSessionID, usAgents.ToArray(), member.AvatarKey, "ENTER", regionID);
                                }
                            }
                        }
                    }
                }

                ChatSessionMember agentMember = FindMember(agentID, groupSessionID);
                if (agentMember != null)
                {
                    // Tell us that we entered
                    var ourblock =
                        new ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock {
                        AgentID      = agentID,
                        CanVoiceChat = agentMember.CanVoiceChat,
                        IsModerator  = agentMember.IsModerator,
                        MuteText     = agentMember.MuteText,
                        MuteVoice    = agentMember.MuteVoice,
                        Transition   = "ENTER"
                    };
                    m_eventQueueService.ChatterBoxSessionAgentListUpdates(
                        groupSessionID, new [] { ourblock }, agentID, "ENTER", findRegionID(agentID));
                }
            }
        }
Exemple #5
0
        public string ChatSessionRequest(IRegionClientCapsService caps, OSDMap req)
        {
            string method    = req ["method"].AsString();
            UUID   sessionID = UUID.Parse(req ["session-id"].AsString());

            switch (method)
            {
            case "start conference": {
                if (SessionExists(sessionID))
                {
                    return("");    // No duplicate sessions
                }
                // Create the session.
                CreateSession(new ChatSession {
                        Members   = new List <ChatSessionMember> (),
                        SessionID = sessionID,
                        Name      = caps.ClientCaps.AccountInfo.Name + " Conference"
                    });

                OSDArray parameters = (OSDArray)req ["params"];
                // Add other invited members.
                foreach (OSD param in parameters)
                {
                    AddDefaultPermsMemberToSession(param.AsUUID(), sessionID);
                }

                // Add us to the session!
                AddMemberToGroup(new ChatSessionMember {
                        AvatarKey        = caps.AgentID,
                        CanVoiceChat     = true,
                        IsModerator      = true,
                        MuteText         = false,
                        MuteVoice        = false,
                        HasBeenAdded     = true,
                        RequestedRemoval = false
                    }, sessionID);


                //Inform us about our room
                ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock block =
                    new ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock {
                    AgentID      = caps.AgentID,
                    CanVoiceChat = true,
                    IsModerator  = true,
                    MuteText     = false,
                    MuteVoice    = false,
                    Transition   = "ENTER"
                };
                m_eventQueueService.ChatterBoxSessionAgentListUpdates(sessionID, new [] { block }, caps.AgentID,
                                                                      "ENTER", caps.RegionID);

                ChatterBoxSessionStartReplyMessage cs = new ChatterBoxSessionStartReplyMessage {
                    VoiceEnabled   = true,
                    TempSessionID  = sessionID,
                    Type           = 1,
                    Success        = true,
                    SessionID      = sessionID,
                    SessionName    = caps.ClientCaps.AccountInfo.Name + " Conference",
                    ModeratedVoice = true
                };
                return(OSDParser.SerializeLLSDXmlString(cs.Serialize()));
            }

            case "accept invitation": {
                // They would like added to the group conversation
                var usAgents    = new List <ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock> ();
                var notUsAgents = new List <ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock> ();

                ChatSession session = GetSession(sessionID);
                if (session != null)
                {
                    ChatSessionMember thismember = FindMember(caps.AgentID, sessionID);
                    if (thismember != null)
                    {
                        // Tell all the other members about the incoming member
                        foreach (ChatSessionMember sessionMember in session.Members)
                        {
                            ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock block =
                                new ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock {
                                AgentID      = sessionMember.AvatarKey,
                                CanVoiceChat = sessionMember.CanVoiceChat,
                                IsModerator  = sessionMember.IsModerator,
                                MuteText     = sessionMember.MuteText,
                                MuteVoice    = sessionMember.MuteVoice,
                                Transition   = "ENTER"
                            };
                            if (sessionMember.AvatarKey == thismember.AvatarKey)
                            {
                                usAgents.Add(block);
                                notUsAgents.Add(block);
                            }
                            else
                            {
                                if (sessionMember.HasBeenAdded)
                                {
                                    // Don't add not joined yet agents. They don't want to be here.
                                    notUsAgents.Add(block);
                                }
                            }
                        }
                        thismember.HasBeenAdded = true;
                        foreach (ChatSessionMember member in session.Members)
                        {
                            if (member.HasBeenAdded)     //Only send to those in the group
                            {
                                UUID regionID = findRegionID(member.AvatarKey);
                                if (regionID != UUID.Zero)
                                {
                                    m_eventQueueService.ChatterBoxSessionAgentListUpdates(
                                        session.SessionID,
                                        member.AvatarKey == thismember.AvatarKey ? notUsAgents.ToArray() : usAgents.ToArray(),
                                        member.AvatarKey, "ENTER",
                                        regionID);
                                }
                            }
                        }
                        return("Accepted");
                    }
                }

                return("");     // no session exists? ... or cannot find member
            }

            case "mute update": {
                // Check if the user is a moderator
                if (!CheckModeratorPermission(caps.AgentID, sessionID))
                {
                    return("");
                }

                OSDMap parameters  = (OSDMap)req ["params"];
                UUID   agentID     = parameters ["agent_id"].AsUUID();
                OSDMap muteInfoMap = (OSDMap)parameters ["mute_info"];

                ChatSessionMember thismember = FindMember(agentID, sessionID);
                if (thismember == null)
                {
                    return("");
                }

                if (muteInfoMap.ContainsKey("text"))
                {
                    thismember.MuteText = muteInfoMap ["text"].AsBoolean();
                }
                if (muteInfoMap.ContainsKey("voice"))
                {
                    thismember.MuteVoice = muteInfoMap ["voice"].AsBoolean();
                }

                ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock block =
                    new ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock {
                    AgentID      = thismember.AvatarKey,
                    CanVoiceChat = thismember.CanVoiceChat,
                    IsModerator  = thismember.IsModerator,
                    MuteText     = thismember.MuteText,
                    MuteVoice    = thismember.MuteVoice,
                    Transition   = "ENTER"
                };

                ChatSession session = GetSession(sessionID);
                // Send an update to all users so that they show the correct permissions
                foreach (ChatSessionMember member in session.Members)
                {
                    if (member.HasBeenAdded)     //Only send to those in the group
                    {
                        UUID regionID = findRegionID(member.AvatarKey);
                        if (regionID != UUID.Zero)
                        {
                            m_eventQueueService.ChatterBoxSessionAgentListUpdates(
                                sessionID, new [] { block }, member.AvatarKey, "", regionID);
                        }
                    }
                }

                return("Accepted");
            }

            case "call": {
                // Implement voice chat for conferences...

                IVoiceService voiceService = m_registry.RequestModuleInterface <IVoiceService> ();
                if (voiceService == null)
                {
                    return("");
                }

                OSDMap resp = voiceService.GroupConferenceCallRequest(caps, sessionID);
                return(OSDParser.SerializeLLSDXmlString(resp));
            }

            default:
                MainConsole.Instance.Warn("ChatSessionRequest : " + method);
                return("");
            }
        }
Exemple #6
0
        private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im)
        {
            IScenePresence presence;

            if ((presence = remoteClient.Scene.GetScenePresence(remoteClient.AgentId)) == null || presence.IsChildAgent)
            {
                return; //Must exist and not be a child
            }
            if (m_debugEnabled)
            {
                MainConsole.Instance.DebugFormat("[GROUPS-MESSAGING]: {0} called", MethodBase.GetCurrentMethod().Name);

                DebugGridInstantMessage(im);
            }

            // Start group IM session
            if ((im.dialog == (byte)InstantMessageDialog.SessionGroupStart))
            {
                if (m_debugEnabled)
                {
                    MainConsole.Instance.InfoFormat("[GROUPS-MESSAGING]: imSessionID({0}) toAgentID({1})", im.imSessionID, im.toAgentID);
                }

                UUID GroupID = im.imSessionID;
                UUID AgentID = im.fromAgentID;

                GroupRecord groupInfo = m_groupData.GetGroupRecord(AgentID, GroupID, null);

                if (groupInfo != null)
                {
                    if (!m_groupsModule.GroupPermissionCheck(AgentID, GroupID, GroupPowers.JoinChat))
                    {
                        return; //They have to be able to join to create a group chat
                    }
                    //Create the session.
                    IEventQueueService queue = remoteClient.Scene.RequestModuleInterface <IEventQueueService>();
                    if (m_groupData.CreateSession(new ChatSession
                    {
                        Members = new List <ChatSessionMember>(),
                        SessionID = GroupID,
                        Name = groupInfo.GroupName
                    }))
                    {
                        m_groupData.AddMemberToGroup(new ChatSessionMember
                        {
                            AvatarKey    = AgentID,
                            CanVoiceChat = false,
                            IsModerator  = GetIsModerator(AgentID, GroupID),
                            MuteText     = false,
                            MuteVoice    = false,
                            HasBeenAdded = true
                        }, GroupID);

#if (!ISWIN)
                        foreach (GroupMembersData gmd in m_groupData.GetGroupMembers(AgentID, GroupID))
                        {
                            if (gmd.AgentID != AgentID)
                            {
                                if ((gmd.AgentPowers & (ulong)GroupPowers.JoinChat) == (ulong)GroupPowers.JoinChat)
                                {
                                    m_groupData.AddMemberToGroup(new ChatSessionMember
                                    {
                                        AvatarKey    = gmd.AgentID,
                                        CanVoiceChat = false,
                                        IsModerator  =
                                            GetIsModerator(gmd.AgentID, GroupID),
                                        MuteText     = false,
                                        MuteVoice    = false,
                                        HasBeenAdded = false
                                    }, GroupID);
                                }
                            }
                        }
#else
                        foreach (GroupMembersData gmd in m_groupData.GetGroupMembers(AgentID, GroupID).Where(gmd => gmd.AgentID != AgentID).Where(gmd => (gmd.AgentPowers & (ulong)GroupPowers.JoinChat) == (ulong)GroupPowers.JoinChat))
                        {
                            m_groupData.AddMemberToGroup(new ChatSessionMember
                            {
                                AvatarKey    = gmd.AgentID,
                                CanVoiceChat = false,
                                IsModerator  =
                                    GetIsModerator(gmd.AgentID, GroupID),
                                MuteText     = false,
                                MuteVoice    = false,
                                HasBeenAdded = false
                            }, GroupID);
                        }
#endif
                        //Tell us that it was made successfully
                        ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, GroupID);
                    }
                    else
                    {
                        ChatSession thisSession = m_groupData.GetSession(GroupID);
                        //A session already exists
                        //Add us
                        m_groupData.AddMemberToGroup(new ChatSessionMember
                        {
                            AvatarKey    = AgentID,
                            CanVoiceChat = false,
                            IsModerator  = GetIsModerator(AgentID, GroupID),
                            MuteText     = false,
                            MuteVoice    = false,
                            HasBeenAdded = true
                        }, GroupID);

                        //Tell us that we entered successfully
                        ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, GroupID);
                        List <ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock> Us =
                            new List <ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock>();
                        List <ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock> NotUsAgents =
                            new List <ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock>();

                        foreach (ChatSessionMember sessionMember in thisSession.Members)
                        {
                            ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock block =
                                new ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock
                            {
                                AgentID      = sessionMember.AvatarKey,
                                CanVoiceChat = sessionMember.CanVoiceChat,
                                IsModerator  = sessionMember.IsModerator,
                                MuteText     = sessionMember.MuteText,
                                MuteVoice    = sessionMember.MuteVoice,
                                Transition   = "ENTER"
                            };
                            if (AgentID == sessionMember.AvatarKey)
                            {
                                Us.Add(block);
                            }
                            if (sessionMember.HasBeenAdded)
                            {
                                // Don't add not joined yet agents. They don't want to be here.
                                NotUsAgents.Add(block);
                            }
                        }
                        foreach (ChatSessionMember member in thisSession.Members)
                        {
                            if (member.AvatarKey == AgentID)
                            {
                                //Tell 'us' about all the other agents in the group
                                queue.ChatterBoxSessionAgentListUpdates(GroupID, NotUsAgents.ToArray(), member.AvatarKey,
                                                                        "ENTER",
                                                                        remoteClient.Scene.RegionInfo.RegionHandle);
                            }
                            else
                            {
                                //Tell 'other' agents about the new agent ('us')
                                IClientAPI otherAgent = GetActiveClient(member.AvatarKey);
                                if (otherAgent != null) //Local, so we can send it directly
                                {
                                    queue.ChatterBoxSessionAgentListUpdates(GroupID, Us.ToArray(), member.AvatarKey,
                                                                            "ENTER",
                                                                            otherAgent.Scene.RegionInfo.RegionHandle);
                                }
                                else
                                {
                                    ISyncMessagePosterService amps =
                                        m_sceneList[0].RequestModuleInterface <ISyncMessagePosterService>();
                                    if (amps != null)
                                    {
                                        OSDMap message = new OSDMap();
                                        message["Method"]  = "GroupSessionAgentUpdate";
                                        message["AgentID"] = AgentID;
                                        message["Message"] = ChatterBoxSessionAgentListUpdates(GroupID, Us.ToArray(),
                                                                                               "ENTER");
                                        amps.Post(message, remoteClient.Scene.RegionInfo.RegionHandle);
                                    }
                                }
                            }
                        }
                    }

                    //Tell us that we entered
                    ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock ourblock =
                        new ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock
                    {
                        AgentID      = AgentID,
                        CanVoiceChat = true,
                        IsModerator  = true,
                        MuteText     = false,
                        MuteVoice    = false,
                        Transition   = "ENTER"
                    };
                    queue.ChatterBoxSessionAgentListUpdates(GroupID, new[] { ourblock }, AgentID, "ENTER",
                                                            remoteClient.Scene.RegionInfo.RegionHandle);
                }
            }
            // Send a message from locally connected client to a group
            else if ((im.dialog == (byte)InstantMessageDialog.SessionSend) && im.message != "")
            {
                UUID GroupID = im.imSessionID;
                UUID AgentID = im.fromAgentID;

                if (m_debugEnabled)
                {
                    MainConsole.Instance.DebugFormat("[GROUPS-MESSAGING]: Send message to session for group {0} with session ID {1}",
                                                     GroupID, im.imSessionID.ToString());
                }

                ChatSessionMember memeber = m_groupData.FindMember(im.imSessionID, AgentID);
                if (memeber == null || memeber.MuteText)
                {
                    return; //Not in the chat or muted
                }
                SendMessageToGroup(im, GroupID);
            }
            else if (im.dialog == (byte)InstantMessageDialog.SessionDrop)
            {
                DropMemberFromSession(remoteClient, im, true);
            }
            else if (im.dialog == 212) //Forwarded sessionDrop
            {
                DropMemberFromSession(remoteClient, im, false);
            }
        }
Exemple #7
0
        private string OnChatSessionRequest(UUID Agent, OSDMap rm)
        {
            string method = rm["method"].AsString();

            UUID sessionid = UUID.Parse(rm["session-id"].AsString());

            IClientAPI         SP = GetActiveClient(Agent);
            IEventQueueService eq = SP.Scene.RequestModuleInterface <IEventQueueService>();

            if (method == "accept invitation")
            {
                //They would like added to the group conversation
                List <ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock> Us =
                    new List <ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock>();
                List <ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock> NotUsAgents =
                    new List <ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock>();

                ChatSession session = m_groupData.GetSession(sessionid);
                if (session != null)
                {
                    ChatSessionMember thismember = m_groupData.FindMember(sessionid, Agent);
                    if (thismember == null)
                    {
                        return(""); //No user with that session
                    }
                    //Tell all the other members about the incoming member
                    thismember.HasBeenAdded = true;
                    foreach (ChatSessionMember sessionMember in session.Members)
                    {
                        ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock block =
                            new ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock
                        {
                            AgentID      = sessionMember.AvatarKey,
                            CanVoiceChat = sessionMember.CanVoiceChat,
                            IsModerator  = sessionMember.IsModerator,
                            MuteText     = sessionMember.MuteText,
                            MuteVoice    = sessionMember.MuteVoice,
                            Transition   = "ENTER"
                        };
                        if (Agent == sessionMember.AvatarKey)
                        {
                            Us.Add(block);
                        }
                        if (sessionMember.HasBeenAdded) // Don't add not joined yet agents. They don't want to be here.
                        {
                            NotUsAgents.Add(block);
                        }
                    }
                    foreach (ChatSessionMember member in session.Members)
                    {
                        if (member.AvatarKey == thismember.AvatarKey)
                        {
                            //Tell 'us' about all the other agents in the group
                            eq.ChatterBoxSessionAgentListUpdates(session.SessionID, NotUsAgents.ToArray(),
                                                                 member.AvatarKey, "ENTER",
                                                                 SP.Scene.RegionInfo.RegionHandle);
                        }
                        else
                        {
                            //Tell 'other' agents about the new agent ('us')
                            IClientAPI otherAgent = GetActiveClient(member.AvatarKey);
                            if (otherAgent != null) //Local, so we can send it directly
                            {
                                eq.ChatterBoxSessionAgentListUpdates(session.SessionID, Us.ToArray(), member.AvatarKey,
                                                                     "ENTER", otherAgent.Scene.RegionInfo.RegionHandle);
                            }
                            else
                            {
                                ISyncMessagePosterService amps =
                                    m_sceneList[0].RequestModuleInterface <ISyncMessagePosterService>();
                                if (amps != null)
                                {
                                    OSDMap message = new OSDMap();
                                    message["Method"]  = "GroupSessionAgentUpdate";
                                    message["AgentID"] = thismember.AvatarKey;
                                    message["Message"] = ChatterBoxSessionAgentListUpdates(session.SessionID,
                                                                                           Us.ToArray(), "ENTER");
                                    amps.Post(message, SP.Scene.RegionInfo.RegionHandle);
                                }
                            }
                        }
                    }
                    return("Accepted");
                }
                else
                {
                    return(""); //not this type of session
                }
            }
            else if (method == "mute update")
            {
                //Check if the user is a moderator
                if (!GetIsModerator(Agent, sessionid))
                {
                    return("");
                }

                OSDMap parameters  = (OSDMap)rm["params"];
                UUID   AgentID     = parameters["agent_id"].AsUUID();
                OSDMap muteInfoMap = (OSDMap)parameters["mute_info"];

                ChatSessionMember thismember = m_groupData.FindMember(sessionid, AgentID);
                if (muteInfoMap.ContainsKey("text"))
                {
                    thismember.MuteText = muteInfoMap["text"].AsBoolean();
                }
                if (muteInfoMap.ContainsKey("voice"))
                {
                    thismember.MuteVoice = muteInfoMap["voice"].AsBoolean();
                }
                MuteUser(sessionid, eq, AgentID, thismember, true);

                return("Accepted");
            }
            else
            {
                MainConsole.Instance.Warn("ChatSessionRequest : " + method);
                return("");
            }
        }
Exemple #8
0
        /// <summary>
        ///   Remove the member from this session
        /// </summary>
        /// <param name = "client"></param>
        /// <param name = "im"></param>
        public void DropMemberFromSession(IClientAPI client, GridInstantMessage im, bool forwardOn)
        {
            ChatSession session = m_groupData.GetSession(im.imSessionID);

            if (session == null)
            {
                return;
            }
            ChatSessionMember member = new ChatSessionMember {
                AvatarKey = UUID.Zero
            };

#if (!ISWIN)
            foreach (ChatSessionMember testmember in session.Members)
            {
                if (testmember.AvatarKey == im.fromAgentID)
                {
                    member = testmember;
                }
            }
#else
            foreach (ChatSessionMember testmember in session.Members.Where(testmember => testmember.AvatarKey == im.fromAgentID))
            {
                member = testmember;
            }
#endif

            if (member.AvatarKey != UUID.Zero)
            {
                member.HasBeenAdded = false;
            }

            if (GetMemeberCount(session) == 0)
            {
                m_groupData.RemoveSession(session.SessionID); //Noone is left!
                return;
            }

            ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock block =
                new ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock
            {
                AgentID      = member.AvatarKey,
                CanVoiceChat = member.CanVoiceChat,
                IsModerator  = member.IsModerator,
                MuteText     = member.MuteText,
                MuteVoice    = member.MuteVoice,
                Transition   = "LEAVE"
            };
            List <UUID>        usersToForwardTo = new List <UUID>();
            IEventQueueService eq = client.Scene.RequestModuleInterface <IEventQueueService>();
            foreach (ChatSessionMember sessionMember in session.Members)
            {
                IClientAPI user = GetActiveClient(sessionMember.AvatarKey);
                if (user != null)
                {
                    eq.ChatterBoxSessionAgentListUpdates(session.SessionID, new[] { block }, sessionMember.AvatarKey,
                                                         "LEAVE", user.Scene.RegionInfo.RegionHandle);
                }
                else
                {
                    usersToForwardTo.Add(sessionMember.AvatarKey);
                }
            }
            if (forwardOn)
            {
                im.dialog = 212; //Don't keep forwarding on other sims
                m_msgTransferModule.SendInstantMessages(im, usersToForwardTo);
            }
        }
Exemple #9
0
        private string OnChatSessionRequest(UUID Agent, OSDMap rm)
        {
            string method = rm["method"].AsString();

            UUID sessionid = UUID.Parse(rm["session-id"].AsString());

            IScenePresence     SP = findScenePresence(Agent);
            IEventQueueService eq = SP.Scene.RequestModuleInterface <IEventQueueService>();

            if (method == "start conference")
            {
                //Create the session.
                CreateSession(new ChatSession
                {
                    Members   = new List <ChatSessionMember>(),
                    SessionID = sessionid,
                    Name      = SP.Name + " Conference"
                });

                OSDArray parameters = (OSDArray)rm["params"];
                //Add other invited members.
                foreach (OSD param in parameters)
                {
                    AddDefaultPermsMemberToSession(param.AsUUID(), sessionid);
                }

                //Add us to the session!
                AddMemberToGroup(new ChatSessionMember
                {
                    AvatarKey    = Agent,
                    CanVoiceChat = true,
                    IsModerator  = true,
                    MuteText     = false,
                    MuteVoice    = false,
                    HasBeenAdded = true
                }, sessionid);


                //Inform us about our room
                ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock block =
                    new ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock
                {
                    AgentID      = Agent,
                    CanVoiceChat = true,
                    IsModerator  = true,
                    MuteText     = false,
                    MuteVoice    = false,
                    Transition   = "ENTER"
                };
                eq.ChatterBoxSessionAgentListUpdates(sessionid, new[] { block }, Agent, "ENTER",
                                                     findScene(Agent).RegionInfo.RegionHandle);

                ChatterBoxSessionStartReplyMessage cs = new ChatterBoxSessionStartReplyMessage
                {
                    VoiceEnabled   = true,
                    TempSessionID  = UUID.Random(),
                    Type           = 1,
                    Success        = true,
                    SessionID      = sessionid,
                    SessionName    = SP.Name + " Conference",
                    ModeratedVoice = true
                };

                return(cs.Serialize().ToString());
            }
            else if (method == "accept invitation")
            {
                //They would like added to the group conversation
                List <ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock> Us =
                    new List <ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock>();
                List <ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock> NotUsAgents =
                    new List <ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock>();

                ChatSession session = GetSession(sessionid);
                if (session != null)
                {
                    ChatSessionMember thismember = FindMember(sessionid, Agent);
                    //Tell all the other members about the incoming member
                    foreach (ChatSessionMember sessionMember in session.Members)
                    {
                        ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock block =
                            new ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock
                        {
                            AgentID      = sessionMember.AvatarKey,
                            CanVoiceChat = sessionMember.CanVoiceChat,
                            IsModerator  = sessionMember.IsModerator,
                            MuteText     = sessionMember.MuteText,
                            MuteVoice    = sessionMember.MuteVoice,
                            Transition   = "ENTER"
                        };
                        if (sessionMember.AvatarKey == thismember.AvatarKey)
                        {
                            Us.Add(block);
                        }
                        else
                        {
                            if (sessionMember.HasBeenAdded)
                            {
                                // Don't add not joined yet agents. They don't want to be here.
                                NotUsAgents.Add(block);
                            }
                        }
                    }
                    thismember.HasBeenAdded = true;
                    foreach (ChatSessionMember member in session.Members)
                    {
                        eq.ChatterBoxSessionAgentListUpdates(session.SessionID,
                                                             member.AvatarKey == thismember.AvatarKey
                                                                 ? NotUsAgents.ToArray()
                                                                 : Us.ToArray(),
                                                             member.AvatarKey, "ENTER",
                                                             findScene(Agent).RegionInfo.RegionHandle);
                    }
                    return("Accepted");
                }
                else
                {
                    return(""); //not this type of session
                }
            }
            else if (method == "mute update")
            {
                //Check if the user is a moderator
                if (!CheckModeratorPermission(Agent, sessionid))
                {
                    return("");
                }

                OSDMap parameters  = (OSDMap)rm["params"];
                UUID   AgentID     = parameters["agent_id"].AsUUID();
                OSDMap muteInfoMap = (OSDMap)parameters["mute_info"];

                ChatSessionMember thismember = FindMember(sessionid, AgentID);
                if (muteInfoMap.ContainsKey("text"))
                {
                    thismember.MuteText = muteInfoMap["text"].AsBoolean();
                }
                if (muteInfoMap.ContainsKey("voice"))
                {
                    thismember.MuteVoice = muteInfoMap["voice"].AsBoolean();
                }

                ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock block =
                    new ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock
                {
                    AgentID      = thismember.AvatarKey,
                    CanVoiceChat = thismember.CanVoiceChat,
                    IsModerator  = thismember.IsModerator,
                    MuteText     = thismember.MuteText,
                    MuteVoice    = thismember.MuteVoice,
                    Transition   = "ENTER"
                };

                // Send an update to the affected user
                eq.ChatterBoxSessionAgentListUpdates(sessionid, new[] { block }, AgentID, "",
                                                     findScene(Agent).RegionInfo.RegionHandle);

                return("Accepted");
            }
            else
            {
                MainConsole.Instance.Warn("ChatSessionRequest : " + method);
                return("");
            }
        }