/// <summary> /// Send chat to all the members of this friend conference /// </summary> /// <param name="client"></param> /// <param name="im"></param> public void SendChatToSession(IClientAPI client, GridInstantMessage im) { ChatSession session; ChatSessions.TryGetValue(UUID.Parse(im.imSessionID.ToString()), out session); if (session == null) { return; } IEventQueueService eq = client.Scene.RequestModuleInterface <IEventQueueService>(); foreach (ChatSessionMember member in session.Members) { if (member.HasBeenAdded) { im.toAgentID = member.AvatarKey.Guid; im.binaryBucket = OpenMetaverse.Utils.StringToBytes(session.Name); im.RegionID = Guid.Empty; im.ParentEstateID = 0; //im.timestamp = 0; m_TransferModule.SendInstantMessage(im); } else { im.toAgentID = member.AvatarKey.Guid; eq.ChatterboxInvitation( session.SessionID , session.Name , new UUID(im.fromAgentID) , im.message , new UUID(im.toAgentID) , im.fromAgentName , im.dialog , im.timestamp , im.offline == 1 , (int)im.ParentEstateID , im.Position , 1 , new UUID(im.imSessionID) , false , OpenMetaverse.Utils.StringToBytes(session.Name) , findScene(member.AvatarKey).RegionInfo.RegionHandle ); } } }
public void SendChatToSession(UUID agentID, GridInstantMessage im) { if (m_doRemoteOnly) { DoRemoteCallPost(true, "InstantMessageServerURI", agentID, im); return; } Util.FireAndForget((o) => { ChatSession session; chatSessions.TryGetValue(im.SessionID, out session); if (session == null) { return; } if (agentID != UUID.Zero) // Not system { ChatSessionMember sender = FindMember(agentID, im.SessionID); if (sender.MuteText) { return; // They have been admin muted, don't allow them to send anything } } var messagesToSend = new Dictionary <string, List <GridInstantMessage> > (); foreach (ChatSessionMember member in session.Members) { if (member.HasBeenAdded) { im.ToAgentID = member.AvatarKey; im.BinaryBucket = Utils.StringToBytes(session.Name); im.RegionID = UUID.Zero; im.ParentEstateID = 0; im.Offline = 0; GridInstantMessage message = new GridInstantMessage(); message.FromOSD(im.ToOSD()); // im.timestamp = 0; string uri = FindRegionURI(member.AvatarKey); if (uri != "") // Check if they are online { // Bulk send all of the instant messages to the same region, so that we don't send them one-by-one over and over if (messagesToSend.ContainsKey(uri)) { messagesToSend [uri].Add(message); } else { messagesToSend.Add(uri, new List <GridInstantMessage> { message }); } } } else if (!member.RequestedRemoval) // If they're requested to leave, don't recontact them { UUID regionID = findRegionID(member.AvatarKey); if (regionID != UUID.Zero) { im.ToAgentID = member.AvatarKey; m_eventQueueService.ChatterboxInvitation( session.SessionID, session.Name, im.FromAgentID, im.Message, im.ToAgentID, im.FromAgentName, im.Dialog, im.Timestamp, im.Offline == 1, (int)im.ParentEstateID, im.Position, 1, im.SessionID, false, Utils.StringToBytes(session.Name), regionID ); } } } foreach (KeyValuePair <string, List <GridInstantMessage> > kvp in messagesToSend) { SendInstantMessages(kvp.Key, kvp.Value); } }); }
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); } 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); UUID toAgentID = new UUID(msg.toAgentID); IClientAPI activeClient = GetActiveClient(toAgentID); if (activeClient != null) { 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); IEventQueueService eq = activeClient.Scene.RequestModuleInterface <IEventQueueService>(); 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 , OpenMetaverse.Utils.StringToBytes(groupInfo.GroupName) , activeClient.Scene.RegionInfo.RegionHandle ); eq.ChatterBoxSessionAgentListUpdates( new UUID(GroupID) , new UUID(msg.fromAgentID) , new UUID(msg.toAgentID) , false //canVoiceChat , false //isModerator , false //text mute , activeClient.Scene.RegionInfo.RegionHandle ); } } } else if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID, GroupID)) { // 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; } }