Exemple #1
0
        public bool FailedToMoveAgentIntoNewRegion(UUID agentID, GridRegion destination)
        {
            FailedToMoveAgentIntoNewRegionRequest request = new FailedToMoveAgentIntoNewRegionRequest();

            request.AgentID  = agentID;
            request.RegionID = destination.RegionID;

            m_syncMessagePoster.Post(destination.ServerURI, request.ToOSD());
            return(true);
        }
Exemple #2
0
        protected object OnGenericEvent(string FunctionName, object parameters)
        {
            if (FunctionName == "UserStatusChange")
            {
                //A user has logged in or out... we need to update friends lists across the grid

                ISyncMessagePosterService asyncPoster    = m_registry.RequestModuleInterface <ISyncMessagePosterService>();
                IFriendsService           friendsService = m_registry.RequestModuleInterface <IFriendsService>();
                if (asyncPoster != null && friendsService != null)
                {
                    //Get all friends
                    object[] info     = (object[])parameters;
                    UUID     us       = UUID.Parse(info[0].ToString());
                    bool     isOnline = bool.Parse(info[1].ToString());

                    List <FriendInfo> friends       = friendsService.GetFriends(us);
                    List <UUID>       OnlineFriends = new List <UUID>();
                    foreach (FriendInfo friend in friends)
                    {
                        if (friend.TheirFlags == -1 || friend.MyFlags == -1)
                        {
                            continue; //Not validiated yet!
                        }
                        UUID FriendToInform = UUID.Zero;
                        if (!UUID.TryParse(friend.Friend, out FriendToInform))
                        {
                            continue;
                        }

                        UserInfo user = m_agentInfoService.GetUserInfo(friend.Friend);
                        //Now find their caps service so that we can find where they are root (and if they are logged in)
                        if (user != null && user.IsOnline)
                        {
                            //Find the root agent
                            OnlineFriends.Add(FriendToInform);
                            //Post!
                            asyncPoster.Post(user.CurrentRegionURI,
                                             SyncMessageHelper.AgentStatusChange(us, FriendToInform, isOnline));
                        }
                    }
                    //If the user is coming online, send all their friends online statuses to them
                    if (isOnline)
                    {
                        UserInfo user = m_agentInfoService.GetUserInfo(us.ToString());
                        if (user != null)
                        {
                            asyncPoster.Post(user.CurrentRegionURI,
                                             SyncMessageHelper.AgentStatusChanges(OnlineFriends, us, true));
                        }
                    }
                }
            }
            return(null);
        }
Exemple #3
0
        public void SendFriendOnlineStatuses(UUID user, bool isOnline)
        {
            ISyncMessagePosterService asyncPoster = m_registry.RequestModuleInterface <ISyncMessagePosterService>();

            if (asyncPoster != null)
            {
                List <FriendInfo> friends = GetFriends(user);
                foreach (FriendInfo friend in friends)
                {
                    if (friend.TheirFlags == -1 || friend.MyFlags == -1)
                    {
                        continue; //Not validiated yet!
                    }
                    UUID FriendToInform = UUID.Zero;
                    if (!UUID.TryParse(friend.Friend, out FriendToInform))
                    {
                        continue;
                    }
                    if ((friend.MyFlags & (int)FriendRights.CanSeeOnline) != (int)FriendRights.CanSeeOnline)
                    {
                        continue;//if we haven't given them the rights to see our online status, don't send the online status
                    }
                    UserInfo friendToInformUser = m_agentInfoService.GetUserInfo(friend.Friend);
                    //Now find their caps service so that we can find where they are root (and if they are logged in)
                    if (friendToInformUser != null && friendToInformUser.IsOnline)
                    {
                        //Post!
                        asyncPoster.Post(friendToInformUser.CurrentRegionURI,
                                         SyncMessageHelper.AgentStatusChange(user, FriendToInform, isOnline));
                    }
                }
            }
        }
 /// <summary>
 ///     Server side
 /// </summary>
 /// <param name="FunctionName"></param>
 /// <param name="parameters"></param>
 /// <returns></returns>
 protected object OnGenericEvent(string FunctionName, object parameters)
 {
     if (FunctionName == "EstateUpdated")
     {
         EstateSettings            es = (EstateSettings)parameters;
         IEstateConnector          estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector>();
         ISyncMessagePosterService asyncPoster     =
             m_registry.RequestModuleInterface <ISyncMessagePosterService>();
         IGridService gridService = m_registry.RequestModuleInterface <IGridService>();
         if (estateConnector != null)
         {
             List <UUID> regions = estateConnector.GetRegions((int)es.EstateID);
             if (regions != null)
             {
                 foreach (UUID region in regions)
                 {
                     //Send the message to update all regions that are in this estate, as a setting changed
                     if (gridService != null && asyncPoster != null)
                     {
                         GridRegion r = gridService.GetRegionByUUID(null, region);
                         if (r != null)
                         {
                             asyncPoster.Post(r.ServerURI,
                                              SyncMessageHelper.UpdateEstateInfo(es.EstateID, region));
                         }
                     }
                 }
             }
         }
     }
     return(null);
 }
        public void CancelTeleport(UUID AgentID, ulong RegionHandle)
        {
            ISyncMessagePosterService syncPoster = m_scenes[0].RequestModuleInterface <ISyncMessagePosterService>();

            if (syncPoster != null)
            {
                syncPoster.Post(SyncMessageHelper.CancelTeleport(AgentID, RegionHandle), RegionHandle);
            }
        }
        public void MessageUser(UUID avatarID, string message)
        {
            //Get required interfaces
            IClientCapsService client = m_capsService.GetClientCapsService(avatarID);

            if (client != null)
            {
                IRegionClientCapsService regionClient = client.GetRootCapsService();
                if (regionClient != null)
                {
                    //Send the message to the client
                    m_messagePost.Post(regionClient.Region.ServerURI,
                                       BuildRequest("GridWideMessage", message, regionClient.AgentID.ToString()));
                    MainConsole.Instance.Info("Message sent to the user.");
                    return;
                }
            }
            MainConsole.Instance.Info("Could not find user to send message to.");
        }
Exemple #7
0
        public bool SendGridMessageRegionPostHandler(Aurora.Framework.Services.GridRegion region, UUID agentID, string message, UUID transactionID)
        {
            OSDMap map = new OSDMap();

            map["AgentID"]       = agentID;
            map["Message"]       = message;
            map["TransactionID"] = transactionID;
            m_syncMessagePosterService.Post(region.ServerURI, map);
            return(true);
        }
Exemple #8
0
        void EventManager_OnStartupFullyComplete(IScene scene, List <string> data)
        {
            //Just send the RegionIsOnline message, it will log out all the agents for the region as well
            ISyncMessagePosterService syncMessage = scene.RequestModuleInterface <ISyncMessagePosterService>();

            if (syncMessage != null)
            {
                syncMessage.Post(SyncMessageHelper.RegionIsOnline(scene.RegionInfo.RegionHandle), scene.RegionInfo.RegionHandle);
            }
        }
Exemple #9
0
        private void SendUpdateMoneyBalanceToClient(UUID toID, UUID transactionID, string serverURI, uint balance, string message)
        {
            OSDMap map = new OSDMap();

            map["Method"]        = "UpdateMoneyBalance";
            map["AgentID"]       = toID;
            map["Amount"]        = balance;
            map["Message"]       = message;
            map["TransactionID"] = transactionID;
            m_syncMessagePoster.Post(serverURI, map);
        }
Exemple #10
0
        void SendInstantMessages(string uri, List <GridInstantMessage> ims)
        {
            ISyncMessagePosterService syncMessagePoster = m_registry.RequestModuleInterface <ISyncMessagePosterService> ();

            if (syncMessagePoster != null)
            {
                OSDMap map = new OSDMap();
                map ["Method"]   = "SendInstantMessages";
                map ["Messages"] = ims.ToOSDArray();
                syncMessagePoster.Post(uri, map);
            }
        }
Exemple #11
0
        public void RemoveRegion(Scene scene)
        {
            ISyncMessagePosterService syncMessage = scene.RequestModuleInterface <ISyncMessagePosterService>();

            if (syncMessage != null)
            {
                syncMessage.Post(SyncMessageHelper.LogoutRegionAgents(scene.RegionInfo.RegionHandle), scene.RegionInfo.RegionHandle);
            }
            scene.EventManager.OnNewClient     -= OnNewClient;
            scene.EventManager.OnClosingClient -= OnClosingClient;
            m_scenes.Remove(scene);
        }
Exemple #12
0
        private byte[] UpdateAvatarAppearance(string path, Stream request, OSHttpRequest httpRequest,
                                              OSHttpResponse httpResponse)
        {
            try
            {
                OSDMap rm          = (OSDMap)OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request));
                int    cof_version = rm["cof_version"].AsInteger();

                bool             success    = false;
                string           error      = "";
                AvatarAppearance appearance = m_appearanceService.BakeAppearance(m_agentID, cof_version);

                OSDMap map = new OSDMap();
                if (appearance == null)
                {
                    map["success"]  = false;
                    map["error"]    = "Wrong COF";
                    map["agent_id"] = m_agentID;
                    return(OSDParser.SerializeLLSDXmlBytes(map));
                }

                OSDMap uaamap = new OSDMap();
                uaamap["Method"]     = "UpdateAvatarAppearance";
                uaamap["AgentID"]    = m_agentID;
                uaamap["Appearance"] = appearance.ToOSD();
                m_syncMessage.Post(m_region.ServerURI, uaamap);
                success = true;

                map["success"]  = success;
                map["error"]    = error;
                map["agent_id"] = m_agentID;

                /*map["avatar_scale"] = appearance.AvatarHeight;
                 * map["textures"] = newBakeIDs.ToOSDArray();
                 * OSDArray visualParams = new OSDArray();
                 * foreach(byte b in appearance.VisualParams)
                 *  visualParams.Add((int)b);
                 * map["visual_params"] = visualParams;*/
                return(OSDParser.SerializeLLSDXmlBytes(map));
            }
            catch (Exception e)
            {
                MainConsole.Instance.Error("[CAPS]: " + e);
            }

            return(null);
        }
Exemple #13
0
        public void SendUpdateMoneyBalanceToClient(UUID toID, UUID transactionID, string serverURI, uint balance, string message)
        {
            if (m_syncMessagePoster == null)
            {
                m_syncMessagePoster = m_registry.RequestModuleInterface <ISyncMessagePosterService>();
            }

            if (m_syncMessagePoster != null)
            {
                OSDMap map = new OSDMap();
                map ["Method"]        = "UpdateMoneyBalance";
                map ["AgentID"]       = toID;
                map ["Amount"]        = balance;
                map ["Message"]       = message;
                map ["TransactionID"] = transactionID;
                m_syncMessagePoster.Post(serverURI, map);
            }
        }
Exemple #14
0
        void m_timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            ISyncMessagePosterService syncMessagePoster = m_scenes[0].RequestModuleInterface <ISyncMessagePosterService>();

            if (syncMessagePoster != null)
            {
                foreach (Scene scene in m_scenes)
                {
                    OSDMap map = new OSDMap();
                    map["Method"] = "RegisterHandlers";
                    syncMessagePoster.Post(map, scene.RegionInfo.RegionHandle);
                }
            }
            else
            {
                m_log.ErrorFormat("[RegisterRegionWithGrid]: ISyncMessagePosterService was null in m_timer_Elapsed;");
            }
        }
        public void RemoveExternalCaps(UUID agentID, GridRegion region)
        {
            OSDMap req = new OSDMap();

            req ["AgentID"] = agentID;
            req ["Region"]  = region.ToOSD();
            req ["Method"]  = "RemoveCaps";

            foreach (string uri in m_servers)
            {
                m_syncPoster.Post(uri, req);
            }

            foreach (var h in GetHandlers(agentID, region.RegionID))
            {
                if (m_allowedCapsModules.Contains(h.Name))
                {
                    h.IncomingCapsDestruction();
                }
            }
        }
        /// <summary>
        /// Tell a single agent to disconnect from the region.
        /// </summary>
        /// <param name="regionHandle"></param>
        /// <param name="agentID"></param>
        public bool IncomingCloseAgent(IScene scene, UUID agentID)
        {
            //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);

            IScenePresence presence = scene.GetScenePresence(agentID);

            if (presence != null)
            {
                bool RetVal = scene.RemoveAgent(presence);

                ISyncMessagePosterService syncPoster = scene.RequestModuleInterface <ISyncMessagePosterService> ();
                if (syncPoster != null)
                {
                    //Tell the grid that we are logged out
                    syncPoster.Post(SyncMessageHelper.DisableSimulator(presence.UUID, scene.RegionInfo.RegionHandle), scene.RegionInfo.RegionHandle);
                }

                return(RetVal);
            }
            return(false);
        }
        protected OSDMap OnMessageReceived(OSDMap message)
        {
            if (!message.ContainsKey("Method"))
            {
                return(null);                        // nothing to do here...
            }
            var method = message ["Method"].AsString();

            ISyncMessagePosterService asyncPost = m_registry.RequestModuleInterface <ISyncMessagePosterService> ();

            //We need to check and see if this is an AgentStatusChange
            if (method == "AgentStatusChange")
            {
                OSDMap innerMessage = (OSDMap)message ["Message"];
                //We got a message, now pass it on to the clients that need it
                UUID AgentID          = innerMessage ["AgentID"].AsUUID();
                UUID FriendToInformID = innerMessage ["FriendToInformID"].AsUUID();
                bool NewStatus        = innerMessage ["NewStatus"].AsBoolean();

                //Do this since IFriendsModule is a scene module, not a ISimulationBase module (not interchangeable)
                ISceneManager manager = m_registry.RequestModuleInterface <ISceneManager> ();
                if (manager != null)
                {
                    foreach (IScene scene in manager.Scenes)
                    {
                        if (scene.GetScenePresence(FriendToInformID) != null &&
                            !scene.GetScenePresence(FriendToInformID).IsChildAgent)
                        {
                            IFriendsModule friendsModule = scene.RequestModuleInterface <IFriendsModule> ();
                            if (friendsModule != null)
                            {
                                //Send the message
                                friendsModule.SendFriendsStatusMessage(FriendToInformID, new [] { AgentID }, NewStatus);
                            }
                        }
                    }
                }
            }
            else if (method == "AgentStatusChanges")
            {
                OSDMap innerMessage = (OSDMap)message ["Message"];
                //We got a message, now pass it on to the clients that need it
                List <UUID> AgentIDs         = ((OSDArray)innerMessage ["AgentIDs"]).ConvertAll <UUID> ((o) => o);
                UUID        FriendToInformID = innerMessage ["FriendToInformID"].AsUUID();
                bool        NewStatus        = innerMessage ["NewStatus"].AsBoolean();

                //Do this since IFriendsModule is a scene module, not a ISimulationBase module (not interchangeable)
                ISceneManager manager = m_registry.RequestModuleInterface <ISceneManager> ();
                if (manager != null)
                {
                    foreach (IScene scene in manager.Scenes)
                    {
                        if (scene.GetScenePresence(FriendToInformID) != null &&
                            !scene.GetScenePresence(FriendToInformID).IsChildAgent)
                        {
                            IFriendsModule friendsModule = scene.RequestModuleInterface <IFriendsModule> ();
                            if (friendsModule != null)
                            {
                                //Send the message
                                friendsModule.SendFriendsStatusMessage(FriendToInformID, AgentIDs.ToArray(), NewStatus);
                            }
                        }
                    }
                }
            }
            else if (method == "FriendGrantRights")
            {
                OSDMap            body             = (OSDMap)message ["Message"];
                UUID              targetID         = body ["Target"].AsUUID();
                IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService> ();
                UserInfo          info;
                if (agentInfoService != null && (info = agentInfoService.GetUserInfo(targetID.ToString())) != null &&
                    info.IsOnline)
                {
                    //Forward the message
                    asyncPost.Post(info.CurrentRegionURI, message);
                }
            }
            else if (method == "FriendshipOffered")
            {
                OSDMap            body             = (OSDMap)message ["Message"];
                UUID              targetID         = body ["Friend"].AsUUID();
                IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService> ();
                UserInfo          info;
                if (agentInfoService != null &&
                    (info = agentInfoService.GetUserInfo(targetID.ToString())) != null &&
                    info.IsOnline)
                {
                    //Forward the message
                    asyncPost.Post(info.CurrentRegionURI, message);
                }
            }
            else if (method == "FriendTerminated")
            {
                OSDMap            body             = (OSDMap)message ["Message"];
                UUID              targetID         = body ["ExFriend"].AsUUID();
                IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService> ();
                UserInfo          info;
                if (agentInfoService != null &&
                    (info = agentInfoService.GetUserInfo(targetID.ToString())) != null &&
                    info.IsOnline)
                {
                    //Forward the message
                    asyncPost.Post(info.CurrentRegionURI, message);
                }
            }
            else if (method == "FriendshipDenied")
            {
                OSDMap            body             = (OSDMap)message ["Message"];
                UUID              targetID         = body ["FriendID"].AsUUID();
                IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService> ();
                UserInfo          info;
                if (agentInfoService != null &&
                    (info = agentInfoService.GetUserInfo(targetID.ToString())) != null &&
                    info.IsOnline)
                {
                    //Forward the message
                    asyncPost.Post(info.CurrentRegionURI, message);
                }
            }
            else if (method == "FriendshipApproved")
            {
                OSDMap            body             = (OSDMap)message ["Message"];
                UUID              targetID         = body ["FriendID"].AsUUID();
                IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService> ();
                UserInfo          info;
                if (agentInfoService != null &&
                    (info = agentInfoService.GetUserInfo(targetID.ToString())) != null &&
                    info.IsOnline)
                {
                    //Forward the message
                    asyncPost.Post(info.CurrentRegionURI, message);
                }
            }
            return(null);
        }
Exemple #18
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("");
            }
        }
        public void OnConnectionClose(IClientAPI client)
        {
            IScenePresence sp = null;

            client.Scene.TryGetScenePresence(client.AgentId, out sp);
            if (client.IsLoggingOut && sp != null & !sp.IsChildAgent)
            {
                MainConsole.Instance.InfoFormat("[ActivityDetector]: Detected logout of user {0} in region {1}", client.Name,
                                                client.Scene.RegionInfo.RegionName);

                //Inform the grid service about it

                if (m_zombieAgents.Contains(client.AgentId))
                {
                    m_zombieAgents.Remove(client.AgentId);
                    return; //They are a known zombie, just clear them out and go on with life!
                }
                AgentPosition agentpos = new AgentPosition
                {
                    AgentID  = sp.UUID,
                    AtAxis   = sp.CameraAtAxis,
                    Center   = sp.CameraPosition,
                    Far      = sp.DrawDistance,
                    LeftAxis = Vector3.Zero,
                    Position = sp.AbsolutePosition
                };
                if (agentpos.Position.X > sp.Scene.RegionInfo.RegionSizeX)
                {
                    agentpos.Position.X = sp.Scene.RegionInfo.RegionSizeX;
                }
                if (agentpos.Position.Y > sp.Scene.RegionInfo.RegionSizeY)
                {
                    agentpos.Position.Y = sp.Scene.RegionInfo.RegionSizeY;
                }
                if (agentpos.Position.Z > sp.Scene.RegionInfo.RegionSizeZ)
                {
                    agentpos.Position.Z = sp.Scene.RegionInfo.RegionSizeZ;
                }
                if (agentpos.Position.X < 0)
                {
                    agentpos.Position.X = 0;
                }
                if (agentpos.Position.Y < 0)
                {
                    agentpos.Position.Y = 0;
                }
                if (agentpos.Position.Z < 0)
                {
                    agentpos.Position.Z = 0;
                }
                agentpos.RegionHandle     = sp.Scene.RegionInfo.RegionHandle;
                agentpos.Size             = sp.PhysicsActor != null ? sp.PhysicsActor.Size : new Vector3(0, 0, 1.8f);
                agentpos.UpAxis           = Vector3.Zero;
                agentpos.Velocity         = sp.Velocity;
                agentpos.UserGoingOffline = true; //Don't attempt to add us into other regions

                //Send the child agent data update
                ISyncMessagePosterService syncPoster = sp.Scene.RequestModuleInterface <ISyncMessagePosterService>();
                if (syncPoster != null)
                {
                    syncPoster.Post(SyncMessageHelper.SendChildAgentUpdate(agentpos, sp.Scene.RegionInfo.RegionHandle),
                                    sp.Scene.RegionInfo.RegionHandle);
                }
                client.Scene.RequestModuleInterface <ISyncMessagePosterService>().Get(
                    SyncMessageHelper.AgentLoggedOut(client.AgentId, client.Scene.RegionInfo.RegionHandle),
                    client.AgentId, client.Scene.RegionInfo.RegionHandle);
            }
        }
Exemple #20
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 #21
0
        protected OSDMap OnMessageReceived(OSDMap message)
        {
            //We need to check and see if this is an GroupSessionAgentUpdate
            if (message.ContainsKey("Method") && message ["Method"] == "GroupSessionAgentUpdate")
            {
                //COMES IN ON WhiteCore.SERVER SIDE
                //Send it on to whomever it concerns
                OSDMap innerMessage = (OSDMap)message ["Message"];
                if (innerMessage ["message"] == "ChatterBoxSessionAgentListUpdates")
                // ONLY forward on this type of message
                {
                    UUID agentID                 = message ["AgentID"];
                    IEventQueueService eqs       = m_registry.RequestModuleInterface <IEventQueueService> ();
                    IAgentInfoService  agentInfo = m_registry.RequestModuleInterface <IAgentInfoService> ();
                    if (agentInfo != null)
                    {
                        UserInfo user = agentInfo.GetUserInfo(agentID.ToString());
                        if (user != null && user.IsOnline)
                        {
                            eqs.Enqueue(innerMessage, agentID, user.CurrentRegionID);
                        }
                    }
                }
            }
            else if (message.ContainsKey("Method") && message ["Method"] == "FixGroupRoleTitles")
            {
                // This message comes in on WhiteCore.Server side from the region
                UUID groupID = message ["GroupID"].AsUUID();
                UUID agentID = message ["AgentID"].AsUUID();
                UUID roleID  = message ["RoleID"].AsUUID();
                byte type    = (byte)message ["Type"].AsInteger();
                IGroupsServiceConnector     con     = Framework.Utilities.DataManager.RequestPlugin <IGroupsServiceConnector> ();
                List <GroupRoleMembersData> members = con.GetGroupRoleMembers(agentID, groupID);
                List <GroupRolesData>       roles   = con.GetGroupRoles(agentID, groupID);
                GroupRolesData everyone             = null;

                foreach (GroupRolesData role in roles.Where(role => role.Name == "Everyone"))
                {
                    everyone = role;
                }

                List <UserInfo> regionsToBeUpdated = new List <UserInfo> ();
                foreach (GroupRoleMembersData data in members)
                {
                    if (data.RoleID == roleID)
                    {
                        // They were affected by the change
                        switch ((GroupRoleUpdate)type)
                        {
                        case GroupRoleUpdate.Create:
                        case GroupRoleUpdate.NoUpdate:     // No changes...
                            break;

                        case GroupRoleUpdate.UpdatePowers: // Possible we don't need to send this?
                        case GroupRoleUpdate.UpdateAll:
                        case GroupRoleUpdate.UpdateData:
                        case GroupRoleUpdate.Delete:
                            if (type == (byte)GroupRoleUpdate.Delete)
                            {
                                // Set them to the most limited role since their role is gone
                                con.SetAgentGroupSelectedRole(data.MemberID, groupID, everyone.RoleID);
                            }

                            // Need to update their title inworld
                            IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService> ();
                            UserInfo          info;
                            if (agentInfoService != null &&
                                (info = agentInfoService.GetUserInfo(agentID.ToString())) != null && info.IsOnline)
                            {
                                // Forward the message
                                regionsToBeUpdated.Add(info);
                            }
                            break;
                        }
                    }
                }
                if (regionsToBeUpdated.Count != 0)
                {
                    ISyncMessagePosterService messagePost = m_registry.RequestModuleInterface <ISyncMessagePosterService> ();
                    if (messagePost != null)
                    {
                        foreach (UserInfo userInfo in regionsToBeUpdated)
                        {
                            OSDMap outgoingMessage = new OSDMap();
                            outgoingMessage ["Method"]   = "ForceUpdateGroupTitles";
                            outgoingMessage ["GroupID"]  = groupID;
                            outgoingMessage ["RoleID"]   = roleID;
                            outgoingMessage ["RegionID"] = userInfo.CurrentRegionID;
                            messagePost.Post(userInfo.CurrentRegionURI, outgoingMessage);
                        }
                    }
                }
            }
            else if (message.ContainsKey("Method") && message ["Method"] == "ForceUpdateGroupTitles")
            {
                // This message comes in on the region side from WhiteCore.Server
                UUID          groupID  = message ["GroupID"].AsUUID();
                UUID          roleID   = message ["RoleID"].AsUUID();
                UUID          regionID = message ["RegionID"].AsUUID();
                IGroupsModule gm       = m_registry.RequestModuleInterface <IGroupsModule> ();
                if (gm != null)
                {
                    gm.UpdateUsersForExternalRoleUpdate(groupID, roleID, regionID);
                }
            }
            return(null);
        }