Exemple #1
0
        /// <summary>
        /// Caller must catch eventual Exceptions.
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="sessionID"></param>
        /// <param name="callback"></param>
        public void GetUserInventory(string userIDStr, UUID sessionID, InventoryReceiptCallback callback)
        {
            UUID userID = UUID.Zero;

            if (UUID.TryParse(userIDStr, out userID))
            {
                lock (m_RequestingInventory)
                {
                    // *HACK ALERT*

                    // If an inventory request times out, it blocks any further requests from the
                    // same user, even after a relog. This is bad, and makes me sad.

                    // Really, we should detect a timeout and report a failure to the callback,
                    // BUT in my testing i found that it's hard to detect a timeout.. sometimes,
                    // a partial response is recieved, and sometimes a null response.

                    // So, for now, add a timer of ten seconds (which is the request timeout).

                    // This should basically have the same effect.

                    lock (m_RequestTime)
                    {
                        if (m_RequestTime.ContainsKey(userID))
                        {
                            TimeSpan interval = DateTime.Now - m_RequestTime[userID];
                            if (interval.TotalSeconds > 10)
                            {
                                m_RequestTime.Remove(userID);
                                if (m_RequestingInventory.ContainsKey(userID))
                                {
                                    m_RequestingInventory.Remove(userID);
                                }
                            }
                        }
                        if (!m_RequestingInventory.ContainsKey(userID))
                        {
                            m_RequestTime.Add(userID, DateTime.Now);
                            m_RequestingInventory.Add(userID, callback);
                        }
                        else
                        {
                            m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetUserInventory - ignoring repeated request for user {0}", userID);
                            return;
                        }
                    }
                }

                m_log.InfoFormat(
                    "[INVENTORY CONNECTOR]: Requesting inventory from {0}/GetInventory/ for user {1}",
                    m_ServerURI, userID);

                RestSessionObjectPosterResponse <Guid, InventoryCollection> requester
                    = new RestSessionObjectPosterResponse <Guid, InventoryCollection>();
                requester.ResponseCallback = InventoryResponse;

                requester.BeginPostObject(m_ServerURI + "/GetInventory/", userID.Guid, sessionID.ToString(), userID.ToString());
            }
        }
        public void GetInventoryItemAsync(InventoryItemBase item, ReturnResponse<InventoryItemBase> callBack)
        {
            System.Console.WriteLine("[HGrid] GetInventory from " + ServerURL);
            try
            {
                RestSessionObjectPosterResponse<InventoryItemBase, InventoryItemBase> requester
                        = new RestSessionObjectPosterResponse<InventoryItemBase, InventoryItemBase>();
                requester.ResponseCallback = callBack;

                requester.BeginPostObject(ServerURL + "/GetItem/", item, string.Empty, string.Empty);
            }
            catch (Exception e)
            {
                System.Console.WriteLine("[HGrid]: Exception posting to inventory: " + e);
            }
        }
        /// <summary>
        /// <see cref="OpenSim.Framework.Communications.IInventoryServices"></see>
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="callback"></param>
        public void RequestInventoryForUser(UUID userID, UUID session_id, InventoryReceiptCallback callback)
        {
            lock (m_RequestingInventory)
            {
                if (!m_RequestingInventory.ContainsKey(userID))
                {
                    m_RequestingInventory.Add(userID, callback);
                }
                else
                {
                    m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: RequestInventoryForUser() - could you not find user profile for {0}", userID);
                    return;
                }
            }

            try
            {
                m_log.InfoFormat(
                    "[OGS1 INVENTORY SERVICE]: Requesting inventory from {0}/GetInventory/ for user {1}",
                    _inventoryServerUrl, userID);

                RestSessionObjectPosterResponse <Guid, InventoryCollection> requester
                    = new RestSessionObjectPosterResponse <Guid, InventoryCollection>();
                requester.ResponseCallback = InventoryResponse;

                requester.BeginPostObject(_inventoryServerUrl + "/GetInventory/", userID.Guid, session_id.ToString(), userID.ToString());
            }
            catch (WebException e)
            {
                if (StatsManager.SimExtraStats != null)
                {
                    StatsManager.SimExtraStats.AddInventoryServiceRetrievalFailure();
                }

                m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Request inventory operation failed, {0} {1}",
                                  e.Source, e.Message);
            }
        }
Exemple #4
0
        public static bool CreateAsset(string uri, AssetBase asset, ReturnResponse<bool> callBack)
        {
            Console.WriteLine("[HGrid] CreateAsset to " + uri);
            try
            {
                RestSessionObjectPosterResponse<AssetBase, bool> requester
                        = new RestSessionObjectPosterResponse<AssetBase, bool>();
                requester.ResponseCallback = callBack;

                requester.BeginPostObject(uri, asset, string.Empty, string.Empty);
            }
            catch (Exception e)
            {
                Console.WriteLine("[HGrid]: Exception posting to inventory: " + e);
                return false;
            }
            return true;
        }
Exemple #5
0
        public static bool RequestAsset(string uri, InventoryItemBase item, ReturnResponse<AssetBase> callBack)
        {
            Console.WriteLine("[HGrid] GetAsset from " + uri);
            try
            {
                RestSessionObjectPosterResponse<InventoryItemBase, AssetBase> requester
                        = new RestSessionObjectPosterResponse<InventoryItemBase, AssetBase>();
                requester.ResponseCallback = callBack;

                requester.BeginPostObject(uri, item, string.Empty, string.Empty);
            }
            catch (Exception e)
            {
                Console.WriteLine("[HGrid]: Exception posting to inventory: " + e);
                return false;
            }
            return true;
        }
Exemple #6
0
        public static void InventoryItemOperation(string uri, InventoryItemBase item, ReturnResponse<InventoryItemBase> callBack)
        {
            Console.WriteLine("[HGrid] Inventory item operation " + uri);
            try
            {
                RestSessionObjectPosterResponse<InventoryItemBase, InventoryItemBase> requester
                        = new RestSessionObjectPosterResponse<InventoryItemBase, InventoryItemBase>();
                requester.ResponseCallback = callBack;

                requester.BeginPostObject(uri, item, string.Empty, string.Empty);
            }
            catch (Exception e)
            {
                Console.WriteLine("[HGrid]: Exception posting to inventory: " + e);
            }
        }
Exemple #7
0
        public static void InventoryFolderOperation(string uri, InventoryFolderBase folder, ReturnResponse<bool> callBack)
        {
            Console.WriteLine("[HGrid] Inventory folder operation " + uri);
            try
            {
                RestSessionObjectPosterResponse<InventoryFolderBase, bool> requester
                        = new RestSessionObjectPosterResponse<InventoryFolderBase, bool>();
                requester.ResponseCallback = callBack;

                requester.BeginPostObject(uri, folder, string.Empty, string.Empty);
            }
            catch (Exception e)
            {
                Console.WriteLine("[HGrid]: Exception posting to inventory: " + e);
            }
        }
Exemple #8
0
        public static void GetInventory(string uri, UUID userID, ReturnResponse<InventoryCollection> callBack)
        {
            Console.WriteLine("[HGrid] GetInventory from " + uri);
            try
            {
                RestSessionObjectPosterResponse<Guid, InventoryCollection> requester
                        = new RestSessionObjectPosterResponse<Guid, InventoryCollection>();
                requester.ResponseCallback = callBack;

                requester.BeginPostObject(uri, userID.Guid, string.Empty, string.Empty);
            }
            catch (Exception e)
            {
                Console.WriteLine("[HGrid]: Exception posting to inventory: " + e);
            }
        }
Exemple #9
0
        public static void FetchInventoryDescendants(string uri, InventoryFolderBase fb, ReturnResponse<InventoryCollection> callBack)
        {
            Console.WriteLine("[HGrid] FetchInventoryDescendants from " + uri);
            try
            {
                RestSessionObjectPosterResponse<InventoryFolderBase, InventoryCollection> requester
                        = new RestSessionObjectPosterResponse<InventoryFolderBase, InventoryCollection>();
                requester.ResponseCallback = callBack;

                requester.BeginPostObject(uri, fb, string.Empty, string.Empty);
            }
            catch (Exception e)
            {
                Console.WriteLine("[HGrid]: Exception posting to inventory: " + e);
            }
        }
        /// <summary>
        /// Caller must catch eventual Exceptions.
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="sessionID"></param>
        /// <param name="callback"></param>
        public void GetUserInventory(string userIDStr, UUID sessionID, InventoryReceiptCallback callback)
        {
            UUID userID = UUID.Zero;
            if (UUID.TryParse(userIDStr, out userID))
            {
                lock (m_RequestingInventory)
                {
                    // *HACK ALERT*

                    // If an inventory request times out, it blocks any further requests from the 
                    // same user, even after a relog. This is bad, and makes me sad.

                    // Really, we should detect a timeout and report a failure to the callback,
                    // BUT in my testing i found that it's hard to detect a timeout.. sometimes,
                    // a partial response is recieved, and sometimes a null response.

                    // So, for now, add a timer of ten seconds (which is the request timeout).

                    // This should basically have the same effect.

                    lock (m_RequestTime)
                    {
                        if (m_RequestTime.ContainsKey(userID))
                        {
                            TimeSpan interval = DateTime.Now - m_RequestTime[userID];
                            if (interval.TotalSeconds > 10)
                            {
                                m_RequestTime.Remove(userID);
                                if (m_RequestingInventory.ContainsKey(userID))
                                {
                                    m_RequestingInventory.Remove(userID);
                                }
                            }
                        }
                        if (!m_RequestingInventory.ContainsKey(userID))
                        {
                            m_RequestTime.Add(userID, DateTime.Now);
                            m_RequestingInventory.Add(userID, callback);
                        }
                        else
                        {
                            m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetUserInventory - ignoring repeated request for user {0}", userID);
                            return;
                        }
                    }
                }

                m_log.InfoFormat(
                    "[INVENTORY CONNECTOR]: Requesting inventory from {0}/GetInventory/ for user {1}",
                    m_ServerURI, userID);

                RestSessionObjectPosterResponse<Guid, InventoryCollection> requester
                    = new RestSessionObjectPosterResponse<Guid, InventoryCollection>();
                requester.ResponseCallback = InventoryResponse;

                requester.BeginPostObject(m_ServerURI + "/GetInventory/", userID.Guid, sessionID.ToString(), userID.ToString());
            }
        }
        public void GetInventoryItemAsync(InventoryItemBase item, ReturnResponse <InventoryItemBase> callBack)
        {
            System.Console.WriteLine("[HGrid] GetInventory from " + ServerURL);
            try
            {
                RestSessionObjectPosterResponse <InventoryItemBase, InventoryItemBase> requester
                    = new RestSessionObjectPosterResponse <InventoryItemBase, InventoryItemBase>();
                requester.ResponseCallback = callBack;

                requester.BeginPostObject(ServerURL + "/GetItem/", item, String.Empty, String.Empty);
            }
            catch (Exception e)
            {
                System.Console.WriteLine("[HGrid]: Exception posting to inventory: " + e);
            }
        }
        /// <summary>
        /// <see cref="OpenSim.Framework.Communications.IInventoryServices"></see>
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="callback"></param>
        public void RequestInventoryForUser(UUID userID, UUID session_id, InventoryReceiptCallback callback)
        {
            lock (m_RequestingInventory)
            {
                if (!m_RequestingInventory.ContainsKey(userID))
                    m_RequestingInventory.Add(userID, callback);
                else
                {
                    m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: RequestInventoryForUser() - could you not find user profile for {0}", userID);
                    return;
                }
            }

            try
            {
                m_log.InfoFormat(
                    "[OGS1 INVENTORY SERVICE]: Requesting inventory from {0}/GetInventory/ for user {1}",
                    _inventoryServerUrl, userID);

                RestSessionObjectPosterResponse<Guid, InventoryCollection> requester
                    = new RestSessionObjectPosterResponse<Guid, InventoryCollection>();
                requester.ResponseCallback = InventoryResponse;

                requester.BeginPostObject(_inventoryServerUrl + "/GetInventory/", userID.Guid, session_id.ToString(), userID.ToString());
            }
            catch (WebException e)
            {
                if (StatsManager.SimExtraStats != null)
                    StatsManager.SimExtraStats.AddInventoryServiceRetrievalFailure();

                m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Request inventory operation failed, {0} {1}",
                    e.Source, e.Message);
            }
        }