Пример #1
0
        /// <summary>
        /// Sets or gets per face media textures.
        /// </summary>
        protected void HandleObjectMediaMessage(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, UUID agentID)
        {
//            m_log.DebugFormat("[MOAP]: Got ObjectMedia path [{0}], raw request [{1}]", path, request);

            try
            {
                OSDMap             osd = (OSDMap)OSDParser.DeserializeLLSDXml(httpRequest.InputStream);
                ObjectMediaMessage omm = new ObjectMediaMessage();
                omm.Deserialize(osd);

                if (omm.Request is ObjectMediaRequest)
                {
                    string ret = HandleObjectMediaRequest(omm.Request as ObjectMediaRequest);
                    if (!string.IsNullOrEmpty(ret))
                    {
                        httpResponse.RawBuffer  = Util.UTF8.GetBytes(ret);
                        httpResponse.StatusCode = (int)HttpStatusCode.OK;
                        return;
                    }
                }
                else if (omm.Request is ObjectMediaUpdate)
                {
                    if (HandleObjectMediaUpdate(omm.Request as ObjectMediaUpdate, agentID))
                    {
                        httpResponse.StatusCode = (int)HttpStatusCode.OK;
                        return;
                    }
                }
                else
                {
                    m_log.ErrorFormat(
                        "[MOAP]: ObjectMediaMessage has unrecognized ObjectMediaBlock of {0}",
                        omm.Request.GetType());
                }
            }
            catch
            {
            }
            httpResponse.StatusCode = (int)HttpStatusCode.BadRequest;
            return;
        }
        /// <summary>
        /// Sets or gets per face media textures.
        /// </summary>
        /// <param name="request"></param>
        /// <param name="path"></param>
        /// <param name="param"></param>
        /// <param name="httpRequest"></param>
        /// <param name="httpResponse"></param>
        /// <returns></returns>
        protected string HandleObjectMediaMessage(
            string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
//            m_log.DebugFormat("[MOAP]: Got ObjectMedia path [{0}], raw request [{1}]", path, request);

            OSDMap             osd = (OSDMap)OSDParser.DeserializeLLSDXml(request);
            ObjectMediaMessage omm = new ObjectMediaMessage();

            omm.Deserialize(osd);

            if (omm.Request is ObjectMediaRequest)
            {
                return(HandleObjectMediaRequest(omm.Request as ObjectMediaRequest));
            }
            else if (omm.Request is ObjectMediaUpdate)
            {
                return(HandleObjectMediaUpdate(path, omm.Request as ObjectMediaUpdate));
            }

            throw new Exception(
                      string.Format(
                          "[MOAP]: ObjectMediaMessage has unrecognized ObjectMediaBlock of {0}",
                          omm.Request.GetType()));
        }
Пример #3
0
        /// <summary>
        ///     Sets or gets per face media textures.
        /// </summary>
        /// <param name="request"></param>
        /// <param name="path"></param>
        /// <param name="httpRequest"></param>
        /// <param name="httpResponse"></param>
        /// <returns></returns>
        protected byte[] HandleObjectMediaMessage(string path, Stream request, OSHttpRequest httpRequest,
                                                  OSHttpResponse httpResponse)
        {
//            MainConsole.Instance.DebugFormat("[MOAP]: Got ObjectMedia path [{0}], raw request [{1}]", path, request);

            OSDMap             osd = (OSDMap)OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request));
            ObjectMediaMessage omm = new ObjectMediaMessage();

            omm.Deserialize(osd);

            if (omm.Request is ObjectMediaRequest)
            {
                return(HandleObjectMediaRequest(omm.Request as ObjectMediaRequest));
            }
            else if (omm.Request is ObjectMediaUpdate)
            {
                return(HandleObjectMediaUpdate(path, omm.Request as ObjectMediaUpdate));
            }

            throw new Exception(
                      string.Format(
                          "[MOAP]: ObjectMediaMessage has unrecognized ObjectMediaBlock of {0}",
                          omm.Request.GetType()));
        }
        /// <summary>
        /// Return a decoded capabilities message as a strongly typed object
        /// </summary>
        /// <param name="eventName">A string containing the name of the capabilities message key</param>
        /// <param name="map">An <see cref="OSDMap"/> to decode</param>
        /// <returns>A strongly typed object containing the decoded information from the capabilities message, or null
        /// if no existing Message object exists for the specified event</returns>
        public static IMessage DecodeEvent(string eventName, OSDMap map)
        {
            IMessage message = null;

            switch (eventName)
            {
            case "AgentGroupDataUpdate": message = new AgentGroupDataUpdateMessage(); break;

            case "AvatarGroupsReply": message = new AgentGroupDataUpdateMessage(); break;     // OpenSim sends the above with the wrong? key

            case "ParcelProperties": message = new ParcelPropertiesMessage(); break;

            case "ParcelObjectOwnersReply": message = new ParcelObjectOwnersReplyMessage(); break;

            case "TeleportFinish": message = new TeleportFinishMessage(); break;

            case "EnableSimulator": message = new EnableSimulatorMessage(); break;

            case "ParcelPropertiesUpdate": message = new ParcelPropertiesUpdateMessage(); break;

            case "EstablishAgentCommunication": message = new EstablishAgentCommunicationMessage(); break;

            case "ChatterBoxInvitation": message = new ChatterBoxInvitationMessage(); break;

            case "ChatterBoxSessionEventReply": message = new ChatterboxSessionEventReplyMessage(); break;

            case "ChatterBoxSessionStartReply": message = new ChatterBoxSessionStartReplyMessage(); break;

            case "ChatterBoxSessionAgentListUpdates": message = new ChatterBoxSessionAgentListUpdatesMessage(); break;

            case "RequiredVoiceVersion": message = new RequiredVoiceVersionMessage(); break;

            case "MapLayer": message = new MapLayerMessage(); break;

            case "ChatSessionRequest": message = new ChatSessionRequestMessage(); break;

            case "CopyInventoryFromNotecard": message = new CopyInventoryFromNotecardMessage(); break;

            case "ProvisionVoiceAccountRequest": message = new ProvisionVoiceAccountRequestMessage(); break;

            case "Viewerstats": message = new ViewerStatsMessage(); break;

            case "UpdateAgentLanguage": message = new UpdateAgentLanguageMessage(); break;

            case "RemoteParcelRequest": message = new RemoteParcelRequestMessage(); break;

            case "UpdateScriptTask": message = new UpdateScriptTaskMessage(); break;

            case "UpdateScriptAgent": message = new UpdateScriptAgentMessage(); break;

            case "SendPostcard": message = new SendPostcardMessage(); break;

            case "UpdateGestureAgentInventory": message = new UpdateGestureAgentInventoryMessage(); break;

            case "UpdateNotecardAgentInventory": message = new UpdateNotecardAgentInventoryMessage(); break;

            case "LandStatReply": message = new LandStatReplyMessage(); break;

            case "ParcelVoiceInfoRequest": message = new ParcelVoiceInfoRequestMessage(); break;

            case "ViewerStats": message = new ViewerStatsMessage(); break;

            case "EventQueueGet": message = new EventQueueGetMessage(); break;

            case "CrossedRegion": message = new CrossedRegionMessage(); break;

            case "TeleportFailed": message = new TeleportFailedMessage(); break;

            case "PlacesReply": message = new PlacesReplyMessage(); break;

            case "UpdateAgentInformation": message = new UpdateAgentInformationMessage(); break;

            case "DirLandReply": message = new DirLandReplyMessage(); break;

            case "ScriptRunningReply": message = new ScriptRunningReplyMessage(); break;

            case "SearchStatRequest": message = new SearchStatRequestMessage(); break;

            case "AgentDropGroup": message = new AgentDropGroupMessage(); break;

            case "ForceCloseChatterBoxSession": message = new ForceCloseChatterBoxSessionMessage(); break;

            case "UploadBakedTexture": message = new UploadBakedTextureMessage(); break;

            case "WebFetchInventoryDescendents": message = new WebFetchInventoryDescendentsMessage(); break;

            case "RegionInfo": message = new RegionInfoMessage(); break;

            case "ObjectMediaNavigate": message = new ObjectMediaNavigateMessage(); break;

            case "ObjectMedia": message = new ObjectMediaMessage(); break;

            case "AttachmentResources": message = AttachmentResourcesMessage.GetMessageHandler(map); break;

            case "LandResources": message = LandResourcesMessage.GetMessageHandler(map); break;
                //case "ProductInfoRequest": message = new ProductInfoRequestMessage(); break;

                // Capabilities TODO:
                // DispatchRegionInfo
                // EstateChangeInfo
                // EventQueueGet
                // FetchInventoryDescendents
                // GroupProposalBallot
                // MapLayerGod
                // NewFileAgentInventory
                // RequestTextureDownload
                // SearchStatRequest
                // SearchStatTracking
                // SendUserReport
                // SendUserReportWithScreenshot
                // ServerReleaseNotes
                // StartGroupProposal
                // UpdateGestureTaskInventory
                // UpdateNotecardTaskInventory
                // ViewerStartAuction
                // UntrustedSimulatorMessage
            }

            if (message != null)
            {
                try
                {
                    message.Deserialize(map);
                    return(message);
                }
                catch (Exception e)
                {
                    Logger.Log("Exception while tring to Deserialize " + eventName + ":" + e.Message + ": " + e.StackTrace, Helpers.LogLevel.Error);
                }

                return(null);
            }
            else
            {
                return(null);
            }
        }