public bool GetExists(string id)
        {
            Aurora.Framework.AssetBase asset = null;
            if (m_Cache != null)
            {
                asset = m_Cache.Get(id);
            }

            if (asset != null)
            {
                return(true);
            }

            List <string> serverURIs = m_registry.RequestModuleInterface <IConfigurationService>().FindValueOf("AssetServerURI");

            //if (m_serverURL != string.Empty)
            //    serverURIs = new List<string>(new string[1] { m_serverURL });
            foreach (string m_ServerURI in serverURIs)
            {
                string uri = m_ServerURI + "/" + id + "/exists";

                bool exists = SynchronousRestObjectRequester.
                              MakeRequest <int, bool>("GET", uri, 0);
                if (exists)
                {
                    return(exists);
                }
            }

            return(false);
        }
        private void UndeliveredMessage(GridInstantMessage im, string reason)
        {
            if ((im.offline != 0) &&
                (!im.fromGroup || (im.fromGroup && m_ForwardOfflineGroupMessages)))
            {
                bool success = SynchronousRestObjectRequester.MakeRequest <GridInstantMessage, bool>(
                    "POST", m_RestURL + "/SaveMessage/", im);

                if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent)
                {
                    IClientAPI client = FindClient(im.fromAgentID);
                    if (client == null)
                    {
                        return;
                    }

                    client.SendInstantMessage(new GridInstantMessage(
                                                  null, im.toAgentID,
                                                  "System", im.fromAgentID,
                                                  (byte)InstantMessageDialog.MessageFromAgent,
                                                  "User is not logged in. " +
                                                  (success ? "Message saved." : "Message not saved"),
                                                  false, new Vector3()));
                }
            }
        }
        private void RetrieveInstantMessages(IClientAPI client)
        {
            if (m_RestURL != "")
            {
                MainConsole.Instance.DebugFormat("[OFFLINE MESSAGING] Retrieving stored messages for {0}", client.AgentId);

                List <GridInstantMessage> msglist = SynchronousRestObjectRequester.MakeRequest
                                                    <UUID, List <GridInstantMessage> >(
                    "POST", m_RestURL + "/RetrieveMessages/", client.AgentId);

                foreach (GridInstantMessage im in msglist)
                {
                    // client.SendInstantMessage(im);

                    // Send through scene event manager so all modules get a chance
                    // to look at this message before it gets delivered.
                    //
                    // Needed for proper state management for stored group
                    // invitations
                    //
                    IScene s = FindScene(client.AgentId);
                    if (s != null)
                    {
                        s.EventManager.TriggerIncomingInstantMessage(im);
                    }
                }
            }
        }
예제 #4
0
        public UUID Store(Aurora.Framework.AssetBase asset)
        {
            AssetBase rasset = Build(asset);

            if ((asset.Flags & AssetFlags.Local) == AssetFlags.Local)
            {
                if (m_Cache != null)
                {
                    m_Cache.Cache(asset.IDString, asset);
                }

                return(asset.ID);
            }

            UUID          newID      = UUID.Zero;
            List <string> serverURIs =
                m_registry.RequestModuleInterface <IConfigurationService>().FindValueOf("AssetServerURI");

            if (m_serverURL != string.Empty)
            {
                serverURIs = new List <string>(new string[1] {
                    m_serverURL
                });
            }
            foreach (string mServerUri in serverURIs)
            {
                string uri = mServerUri + "/";
                try
                {
                    string request = SynchronousRestObjectRequester.MakeRequest <AssetBase, string>("POST", uri, rasset);

                    UUID.TryParse(request, out newID);
                }
                catch (Exception e)
                {
                    MainConsole.Instance.WarnFormat("[ASSET CONNECTOR]: Unable to send asset {0} to asset server. Reason: {1}", asset.ID, e.Message);
                }

                if (newID != UUID.Zero)
                {
                    // Placing this here, so that this work with old asset servers that don't send any reply back
                    // SynchronousRestObjectRequester returns somethins that is not an empty string
                    asset.ID = newID;

                    if (m_Cache != null)
                    {
                        m_Cache.Cache(asset.IDString, asset);
                    }
                }
                else
                {
                    return(asset.ID); //OPENSIM
                }
            }
            return(newID);
        }
예제 #5
0
        public Aurora.Framework.AssetBase Get(string id)
        {
            Aurora.Framework.AssetBase asset = null;
            AssetBase rasset = null;

            if (m_Cache != null)
            {
                asset = m_Cache.Get(id);
                if ((asset != null) && ((asset.Data != null) && (asset.Data.Length != 0)))
                {
                    return(asset);
                }
            }

            List <string> serverURIs = m_registry == null
                                          ? null
                                          : m_registry.RequestModuleInterface <IConfigurationService>().FindValueOf(
                "AssetServerURI");

            if (m_serverURL != string.Empty)
            {
                serverURIs = new List <string>(new string[1] {
                    m_serverURL
                });
            }
            if (serverURIs != null)
            {
                foreach (string mServerUri in serverURIs)
                {
                    string uri = mServerUri + "/" + id;
                    rasset = SynchronousRestObjectRequester.MakeRequest <int, AssetBase>("GET", uri, 0);
                    asset  = TearDown(rasset);
                    if (m_Cache != null && asset != null)
                    {
                        m_Cache.Cache(asset.IDString, asset);
                    }
                    if (asset != null)
                    {
                        return(asset);
                    }
                }
            }
            return(null);
        }
예제 #6
0
        public UUID UpdateContent(UUID id, byte[] data)
        {
            Aurora.Framework.AssetBase asset = null;

            if (m_Cache != null)
            {
                asset = m_Cache.Get(id.ToString());
            }

            if (asset == null)
            {
                asset = Get(id.ToString());
                if (asset == null)
                {
                    return(UUID.Zero);
                }
            }
            asset.Data = data;

            List <string> serverURIs = m_registry.RequestModuleInterface <IConfigurationService>().FindValueOf("AssetServerURI");

            if (m_serverURL != string.Empty)
            {
                serverURIs = new List <string>(new string[1] {
                    m_serverURL
                });
            }
            foreach (string m_ServerURI in serverURIs)
            {
                string uri = m_ServerURI + "/" + id;

                if (SynchronousRestObjectRequester.
                    MakeRequest <AssetBase, bool>("POST", uri, Build(asset)))
                {
                    if (m_Cache != null)
                    {
                        m_Cache.Cache(asset.IDString, asset);
                    }

                    return(asset.ID);
                }
            }
            return(UUID.Zero);
        }