예제 #1
0
        private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im)
        {
            if (m_debugEnabled)
            {
                m_log.DebugFormat("[Groups.Messaging]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);

                DebugGridInstantMessage(im);
            }

            // Start group IM session
            if ((im.dialog == (byte)InstantMessageDialog.SessionGroupStart))
            {
                if (m_debugEnabled)
                {
                    m_log.InfoFormat("[Groups.Messaging]: imSessionID({0}) toAgentID({1})", im.imSessionID, im.toAgentID);
                }

                UUID GroupID = new UUID(im.imSessionID);
                UUID AgentID = new UUID(im.fromAgentID);

                GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero.ToString(), GroupID, null);

                if (groupInfo != null)
                {
                    AgentInvitedToGroupChatSession(AgentID.ToString(), GroupID);

                    ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, GroupID);

                    IEventQueue queue = remoteClient.Scene.RequestModuleInterface <IEventQueue>();
                    queue.ChatterBoxSessionAgentListUpdates(
                        GroupID
                        , AgentID
                        , new UUID(im.toAgentID)
                        , false //canVoiceChat
                        , false //isModerator
                        , false //text mute
                        , true
                        );
                }
            }

            // Send a message from locally connected client to a group
            if ((im.dialog == (byte)InstantMessageDialog.SessionSend))
            {
                UUID GroupID = new UUID(im.imSessionID);
                UUID AgentID = new UUID(im.fromAgentID);

                if (m_debugEnabled)
                {
                    m_log.DebugFormat("[Groups.Messaging]: Send message to session for group {0} with session ID {1}", GroupID, im.imSessionID.ToString());
                }

                //If this agent is sending a message, then they want to be in the session
                AgentInvitedToGroupChatSession(AgentID.ToString(), GroupID);

                SendMessageToGroup(im, GroupID);
            }
        }
예제 #2
0
        private void AddAgentToSession(UUID AgentID, UUID GroupID, GridInstantMessage msg)
        {
            if (m_log.IsDebugEnabled)
            {
                m_log.DebugFormat("[GroupsMessagingModule]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
            }
            // Agent not in session and hasn't dropped from session
            // Add them to the session for now, and Invite them
            AgentInvitedToGroupChatSession(AgentID.ToString(), GroupID);

            IClientAPI activeClient = GetActiveClient(AgentID);

            if (activeClient != null)
            {
                GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero.ToString(), GroupID, null);
                if (groupInfo != null)
                {
                    if (m_log.IsDebugEnabled)
                    {
                        m_log.DebugFormat("[GroupsMessagingModule]: Sending chatterbox invite instant message");
                    }

                    // Force? open the group session dialog???
                    // and simultanously deliver the message, so we don't need to do a seperate client.SendInstantMessage(msg);
                    IEventQueue eq = activeClient.Scene.RequestModuleInterface <IEventQueue>();
                    eq.ChatterboxInvitation(
                        GroupID
                        , groupInfo.GroupName
                        , new UUID(msg.fromAgentID)
                        , msg.message
                        , AgentID
                        , msg.fromAgentName
                        , msg.dialog
                        , msg.timestamp
                        , msg.offline == 1
                        , (int)msg.ParentEstateID
                        , msg.Position
                        , 1
                        , new UUID(msg.imSessionID)
                        , msg.fromGroup
                        , OpenMetaverse.Utils.StringToBytes(groupInfo.GroupName)
                        );

                    eq.ChatterBoxSessionAgentListUpdates(
                        new UUID(GroupID)
                        , AgentID
                        , new UUID(msg.toAgentID)
                        , false //canVoiceChat
                        , false //isModerator
                        , false //text mute
                        );
                }
            }
        }
        private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im)
        {
            if (m_debugEnabled)
            {
                m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);

                DebugGridInstantMessage(im);
            }

            // Start group IM session
            if ((im.dialog == (byte)InstantMessageDialog.SessionGroupStart))
            {
                UUID groupID = new UUID(im.toAgentID);

                GroupRecord groupInfo = m_groupsModule.GetGroupRecord(groupID);
                if (groupInfo != null)
                {
                    if (m_debugEnabled)
                    {
                        m_log.DebugFormat("[GROUPS-MESSAGING]: Start Group Session for {0}", groupInfo.GroupName);
                    }

                    AddAgentToGroupSession(im.fromAgentID, im.imSessionID);

                    ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, groupID);

                    IEventQueue queue = remoteClient.Scene.RequestModuleInterface <IEventQueue>();
                    queue.ChatterBoxSessionAgentListUpdates(
                        new UUID(groupID)
                        , new UUID(im.fromAgentID)
                        , new UUID(im.fromAgentID)
                        , false //canVoiceChat
                        , false //isModerator
                        , false //text mute
                        , im.dialog
                        );
                }
            }

            // Send a message from locally connected client to a group
            if ((im.dialog == (byte)InstantMessageDialog.SessionSend))
            {
                UUID groupID = new UUID(im.toAgentID);

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

                SendMessageToGroup(remoteClient, im, groupID);
            }
        }
        private void AddAgentToSession(UUID AgentID, UUID GroupID, GridInstantMessage msg)
        {
            // Agent not in session and hasn't dropped from session
            // Add them to the session for now, and Invite them
            AgentInvitedToGroupChatSession(AgentID.ToString(), GroupID);

            IClientAPI activeClient = GetActiveClient(AgentID);

            if (activeClient != null)
            {
                GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero.ToString(), GroupID, null);
                if (groupInfo != null)
                {
                    if (m_debugEnabled)
                    {
                        m_log.DebugFormat("[Groups.Messaging]: Sending chatterbox invite instant message");
                    }

                    UUID fromAgent = new UUID(msg.fromAgentID);
                    // Force? open the group session dialog???
                    // and simultanously deliver the message, so we don't need to do a seperate client.SendInstantMessage(msg);
                    IEventQueue eq = activeClient.Scene.RequestModuleInterface <IEventQueue>();
                    if (eq != null)
                    {
                        eq.ChatterboxInvitation(
                            GroupID
                            , groupInfo.GroupName
                            , fromAgent
                            , msg.message
                            , AgentID
                            , msg.fromAgentName
                            , msg.dialog
                            , msg.timestamp
                            , msg.offline == 1
                            , (int)msg.ParentEstateID
                            , msg.Position
                            , 1
                            , new UUID(msg.imSessionID)
                            , msg.fromGroup
                            , OpenMetaverse.Utils.StringToBytes(groupInfo.GroupName)
                            );

                        var update  = new GroupChatListAgentUpdateData(AgentID);
                        var updates = new List <GroupChatListAgentUpdateData> {
                            update
                        };
                        eq.ChatterBoxSessionAgentListUpdates(GroupID, new UUID(msg.toAgentID), updates);
                    }
                }
            }
        }
        private void NotifyNewSessionUserOfExisting(Guid sessionID, Guid userID)
        {
            Guid[] participants;
            lock (m_sessionLock)
            {
                if (!m_agentsInGroupSession.ContainsKey(sessionID))
                {
                    return;
                }
                participants = new Guid[m_agentsInGroupSession[sessionID].Count];
                m_agentsInGroupSession[sessionID].CopyTo(participants);
            }

            IEventQueue queue = this.m_sceneList[0].RequestModuleInterface <IEventQueue>();

            foreach (Guid participant in participants)
            {
                // This condition disables participant list updates, except for the current user,
                // because it only supports participants in the current region.
                // When they support notification across regions, we can remove the condition.
                if (participant != userID)
                {
                    continue;
                }

                // Notify existing participant of user transition.
                queue.ChatterBoxSessionAgentListUpdates(
                    new UUID(sessionID)
                    , new UUID(participant)
                    , new UUID(userID)
                    , false //canVoiceChat
                    , false //isModerator
                    , false //text mute
                    , (byte)InstantMessageDialog.SessionGroupStart
                    );
            }
        }
        private void ProcessMessageFromGroupSession(GridInstantMessage msg)
        {
            if (m_debugEnabled)
            {
                m_log.DebugFormat("[GROUPS-MESSAGING]: Session message from {0} going to agent {1}", msg.fromAgentName, msg.toAgentID);
            }

            switch (msg.dialog)
            {
            case (byte)InstantMessageDialog.SessionAdd:
                AddAgentToGroupSession(msg.fromAgentID, msg.imSessionID);
                break;

            case (byte)InstantMessageDialog.SessionDrop:
                RemoveAgentFromGroupSession(msg.fromAgentID, msg.imSessionID);
                break;

            case (byte)InstantMessageDialog.SessionSend:
                if (!m_agentsInGroupSession.ContainsKey(msg.toAgentID) &&
                    !m_agentsDroppedSession.ContainsKey(msg.toAgentID))
                {
                    // Agent not in session and hasn't dropped from session
                    // Add them to the session for now, and Invite them
                    AddAgentToGroupSession(msg.toAgentID, msg.imSessionID);

                    UUID       toAgentID    = new UUID(msg.toAgentID);
                    IClientAPI activeClient = GetActiveClient(toAgentID);
                    if (activeClient != null)
                    {
                        UUID groupID = new UUID(msg.fromAgentID);

                        GroupRecord groupInfo = m_groupsModule.GetGroupRecord(groupID);
                        if (groupInfo != null)
                        {
                            if (m_debugEnabled)
                            {
                                m_log.DebugFormat("[GROUPS-MESSAGING]: Sending chatterbox invite instant message");
                            }

                            // Force? open the group session dialog???
                            IEventQueue eq = activeClient.Scene.RequestModuleInterface <IEventQueue>();
                            eq.ChatterboxInvitation(
                                groupID
                                , groupInfo.GroupName
                                , new UUID(msg.fromAgentID)
                                , msg.message, new UUID(msg.toAgentID)
                                , msg.fromAgentName
                                , msg.dialog
                                , msg.timestamp
                                , msg.offline == 1
                                , (int)msg.ParentEstateID
                                , msg.Position
                                , 1
                                , new UUID(msg.imSessionID)
                                , msg.fromGroup
                                , Utils.StringToBytes(groupInfo.GroupName)
                                );

                            eq.ChatterBoxSessionAgentListUpdates(
                                new UUID(groupID)
                                , new UUID(msg.fromAgentID)
                                , new UUID(msg.toAgentID)
                                , false     //canVoiceChat
                                , false     //isModerator
                                , false     //text mute
                                );
                        }
                    }
                }
                else if (!m_agentsDroppedSession.ContainsKey(msg.toAgentID))
                {
                    // User hasn't dropped, so they're in the session,
                    // maybe we should deliver it.
                    IClientAPI client = GetActiveClient(new UUID(msg.toAgentID));
                    if (client != null)
                    {
                        // Deliver locally, directly
                        if (m_debugEnabled)
                        {
                            m_log.DebugFormat("[GROUPS-MESSAGING]: Delivering to {0} locally", client.Name);
                        }
                        client.SendInstantMessage(msg);
                    }
                    else
                    {
                        m_log.WarnFormat("[GROUPS-MESSAGING]: Received a message over the grid for a client that isn't here: {0}", msg.toAgentID);
                    }
                }
                break;

            default:
                m_log.WarnFormat("[GROUPS-MESSAGING]: I don't know how to proccess a {0} message.", ((InstantMessageDialog)msg.dialog).ToString());
                break;
            }
        }
예제 #7
0
        private void ProcessMessageFromGroupSession(GridInstantMessage msg, IClientAPI client)
        {
            if (m_debugEnabled)
            {
                m_log.DebugFormat(
                    "[GROUPS-MESSAGING]: Session message from {0} going to agent {1}, sessionID {2}, type {3}",
                    msg.fromAgentName, msg.toAgentID, msg.imSessionID, (InstantMessageDialog)msg.dialog);
            }

            UUID        fromAgentID = new UUID(msg.fromAgentID);
            UUID        GroupID     = new UUID(msg.imSessionID);
            IEventQueue eq          = client.Scene.RequestModuleInterface <IEventQueue>();

            switch (msg.dialog)
            {
            case (byte)InstantMessageDialog.SessionAdd:
                m_groupData.AgentInvitedToGroupChatSession(fromAgentID, GroupID);
                if (eq != null)
                {
                    eq.ChatterBoxSessionAgentListUpdates(
                        GroupID
                        , fromAgentID
                        , client.AgentId
                        , false    //canVoiceChat
                        , false    //isModerator
                        , false    //text mute
                        , true     // enter
                        );
                }
                break;

            case (byte)InstantMessageDialog.SessionDrop:
                m_groupData.AgentDroppedFromGroupChatSession(fromAgentID, GroupID);
                if (eq != null)
                {
                    eq.ChatterBoxSessionAgentListUpdates(
                        GroupID
                        , fromAgentID
                        , client.AgentId
                        , false         //canVoiceChat
                        , false         //isModerator
                        , false         //text mute
                        , false         // leave
                        );
                }
                break;

            case (byte)InstantMessageDialog.SessionSend:
                if (!m_groupData.hasAgentDroppedGroupChatSession(client.AgentId, GroupID))
                {
                    if (!m_groupData.hasAgentBeenInvitedToGroupChatSession(client.AgentId, GroupID))
                    {
                        GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null);
                        if (groupInfo != null)
                        {
                            if (m_debugEnabled)
                            {
                                m_log.DebugFormat("[GROUPS-MESSAGING]: Sending chatterbox invite instant message");
                            }

                            if (eq != null)
                            {
                                eq.ChatterboxInvitation(
                                    GroupID
                                    , groupInfo.GroupName
                                    , fromAgentID
                                    , msg.message
                                    , client.AgentId
                                    , msg.fromAgentName
                                    , msg.dialog
                                    , msg.timestamp
                                    , msg.offline == 1
                                    , (int)msg.ParentEstateID
                                    , msg.Position
                                    , 1
                                    , new UUID(msg.imSessionID)
                                    , msg.fromGroup
                                    , Utils.StringToBytes(groupInfo.GroupName)
                                    );
                            }
                        }
                    }
                    else
                    {
                        client.SendInstantMessage(msg);
                    }

//                        if (!m_groupData.hasAgentBeenInvitedToGroupChatSession(fromAgentID, GroupID))
                    {
                        m_groupData.AgentInvitedToGroupChatSession(fromAgentID, GroupID);
                        eq.ChatterBoxSessionAgentListUpdates(
                            GroupID
                            , fromAgentID
                            , client.AgentId
                            , false        //canVoiceChat
                            , false        //isModerator
                            , false        //text mute
                            , true         // enter
                            );
                    }
                }
                break;

            default:
                client.SendInstantMessage(msg);
                break;;
            }
        }
        private void ProcessMessageFromGroupSession(GridInstantMessage msg, IClientAPI client)
        {
            if (m_debugEnabled)
            {
                m_log.DebugFormat(
                    "[GROUPS-MESSAGING]: Session message from {0} going to agent {1}, sessionID {2}, type {3}",
                    msg.fromAgentName, msg.toAgentID, msg.imSessionID, (InstantMessageDialog)msg.dialog);
            }

            UUID AgentID = new UUID(msg.fromAgentID);
            UUID GroupID = new UUID(msg.imSessionID);

            switch (msg.dialog)
            {
            case (byte)InstantMessageDialog.SessionAdd:
                m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);
                break;

            case (byte)InstantMessageDialog.SessionDrop:
                m_groupData.AgentDroppedFromGroupChatSession(AgentID, GroupID);
                break;

            case (byte)InstantMessageDialog.SessionSend:
                if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID, GroupID) &&
                    !m_groupData.hasAgentBeenInvitedToGroupChatSession(AgentID, GroupID)
                    )
                {
                    // Agent not in session and hasn't dropped from session
                    // Add them to the session for now, and Invite them
                    m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);

                    GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null);
                    if (groupInfo != null)
                    {
                        if (m_debugEnabled)
                        {
                            m_log.DebugFormat("[GROUPS-MESSAGING]: Sending chatterbox invite instant message");
                        }

                        // Force? open the group session dialog???
                        // and simultanously deliver the message, so we don't need to do a seperate client.SendInstantMessage(msg);
                        IEventQueue eq = client.Scene.RequestModuleInterface <IEventQueue>();
                        eq.ChatterboxInvitation(
                            GroupID
                            , groupInfo.GroupName
                            , new UUID(msg.fromAgentID)
                            , msg.message
                            , new UUID(msg.toAgentID)
                            , msg.fromAgentName
                            , msg.dialog
                            , msg.timestamp
                            , msg.offline == 1
                            , (int)msg.ParentEstateID
                            , msg.Position
                            , 1
                            , new UUID(msg.imSessionID)
                            , msg.fromGroup
                            , Utils.StringToBytes(groupInfo.GroupName)
                            );

                        eq.ChatterBoxSessionAgentListUpdates(
                            new UUID(GroupID)
                            , new UUID(msg.fromAgentID)
                            , new UUID(msg.toAgentID)
                            , false     //canVoiceChat
                            , false     //isModerator
                            , false     //text mute
                            );
                    }

                    break;
                }
                else if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID, GroupID))
                {
                    // User hasn't dropped, so they're in the session,
                    // maybe we should deliver it.
                    client.SendInstantMessage(msg);
                }

                break;

            default:
                client.SendInstantMessage(msg);

                break;;
            }
        }