Exemplo n.º 1
0
        /// <summary>
        /// Process individual messages that arrive via the EventQueue and convert each indvidual event into a format
        /// suitable for processing by the IMessage system
        /// </summary>
        /// <param name="req"></param>
        /// <param name="stage"></param>
        /// <returns></returns>
        private bool EventQueueGetHandler(CapsRequest req, CapsStage stage)
        {
            if (stage == CapsStage.Response && req.Response is OSDMap)
            {
                OSDMap map = (OSDMap)req.Response;

                if (map.ContainsKey("events"))
                {
                    OSDArray eventsArray = (OSDArray)map["events"];

                    for (int i = 0; i < eventsArray.Count; i++)
                    {
                        OSDMap bodyMap = (OSDMap)eventsArray[i];
                        if (OnEventMessageLog != null)
                        {
                            CapInfo     capInfo = new CapInfo(req.Info.URI, req.Info.Sim, bodyMap["message"].AsString());
                            CapsRequest capReq  = new CapsRequest(capInfo);
                            capReq.RequestHeaders  = req.RequestHeaders;
                            capReq.ResponseHeaders = req.ResponseHeaders;
                            capReq.Request         = null; // req.Request;
                            capReq.RawRequest      = null; // req.RawRequest;
                            capReq.RawResponse     = OSDParser.SerializeLLSDXmlBytes(bodyMap);
                            capReq.Response        = bodyMap;

                            OnEventMessageLog(capReq, CapsStage.Response);
                        }
                    }
                }
            }
            return(false);
        }
Exemplo n.º 2
0
 private bool CapsHandler(CapsRequest req, CapsStage stage)
 {
     if (OnMessageLog != null)
     {
         OnMessageLog(req, stage);
     }
     return(false);
 }
Exemplo n.º 3
0
        bool UpdateNotecardHandler(CapsRequest req, CapsStage stage)
        {
            Console.WriteLine(">> UpdateNotecard " + stage.ToString() + " to " + req.Info.URI);

            if (stage != CapsStage.Response) return true; // shortcircuit, so don't foward to sim

            string uri = (string)UserInventory.CapsHandlers["UpdateNotecardAgentInventory"]; //req.Info.URI;
            Console.WriteLine("[GRIDER]: Forwarding caps request to " + uri);
            Console.WriteLine("[GRIDER]:  request is " + req.Request);
            proxy.ForwardCaps(uri, req);
            return false;
        }
Exemplo n.º 4
0
        bool SeedCapHandler(CapsRequest req, CapsStage stage)
        {
            Console.WriteLine(">> SeedCapability " + stage.ToString() + " to " + req.Info.URI);

            if (stage != CapsStage.Response) return false;

            if (req.Response.Type == OSDType.Map)
            {
                OSDMap nm = (OSDMap)req.Response;

                // First, let's fix the EventQueue Cap
                if (nm["EventQueueGet"] != null)
                    Console.WriteLine("[GRIDER]: Original EQGet Cap " + nm["EventQueueGet"].AsString());
                else
                    Console.WriteLine("[GRIDER]: SeedCap response did not have EQGet Cap");

                //Agent.NextEQID = UUID.Random().ToString();
                string eqkey = Agent.LocalEQCAP + Agent.NextEQID + "/";

                nm["EventQueueGet"] = OSD.FromString(proxy.loginURI + eqkey);
                Console.WriteLine("[GRIDFER]: New EQGet Cap " + nm["EventQueueGet"].AsString());

                if (!proxy.KnownCaps.ContainsKey(eqkey))
                {
                    CapInfo newCap = new CapInfo(eqkey, req.Info.Sim, eqkey);
                    newCap.AddDelegate(new CapsDelegate(LocalEQHandler));
                    lock (proxy)
                        proxy.KnownCaps[eqkey] = newCap;
                }

                // Then, let's fix the UpdateScriptAgent Cap
                if (nm["UpdateScriptAgent"] != null)
                    Console.WriteLine("[GRIDER]: Original UpdateScriptAgent Cap " + nm["UpdateScriptAgent"].AsString());
                else
                    Console.WriteLine("[GRIDER]: SeedCap response did not have UpdateScriptAgent Cap");
                if (UserInventory.CapsHandlers.ContainsKey("UpdateScriptAgent"))
                {
                    string newcap = (string)UserInventory.CapsHandlers["UpdateScriptAgent"];
                    nm["UpdateScriptAgent"] = OSD.FromString(proxy.loginURI + newcap);
                    nm["UpdateNotecardAgentInventory"] = OSD.FromString(proxy.loginURI + newcap);
                    nm["UpdateScriptAgentInventory"] = OSD.FromString(proxy.loginURI + newcap);
                    if (!proxy.KnownCaps.ContainsKey(newcap))
                    {
                        CapInfo newCap = new CapInfo(newcap, req.Info.Sim, "UpdateScriptAgent");
                        lock (proxy)
                            proxy.KnownCaps[newcap] = newCap;
                    }
                    nm["UpdateScriptAgent"] = OSD.FromString(newcap);
                    nm["UpdateNotecardAgentInventory"] = OSD.FromString(newcap);
                    nm["UpdateScriptAgentInventory"] = OSD.FromString(newcap);

                    Console.WriteLine("[GRIDER]: New UpdateScriptAgent Cap " + nm["UpdateScriptAgent"].AsString());
                }
                else
                    Console.WriteLine("[GRIDER]: UserInventory does not contain UpdateScriptAgent Cap");
                if (UserInventory.CapsHandlers.ContainsKey("NewFileAgentInventory"))
                {
                    string newcap = (string)UserInventory.CapsHandlers["NewFileAgentInventory"];
                    if (!proxy.KnownCaps.ContainsKey(newcap))
                    {
                        CapInfo newCap = new CapInfo(newcap, req.Info.Sim, "NewFileAgentInventory");
                        lock (proxy)
                            proxy.KnownCaps[newcap] = newCap;
                    }
                    nm["NewFileAgentInventory"] = OSD.FromString(newcap);

                    Console.WriteLine("[GRIDER]: New NewFileAgentInventory Cap " + nm["NewFileAgentInventory"].AsString());
                }
                else
                    Console.WriteLine("[GRIDER]: UserInventory does not contain NewFileAgentInventory Cap");

            }

            //Console.WriteLine("---------------");
            //lock (this)
            //{
            //    foreach (KeyValuePair<string, CapInfo> kvp in KnownCaps)
            //    {
            //        Console.WriteLine(" >> Key: " + kvp.Key + "; Value: " + kvp.Value.CapType);
            //    }
            //}
            //Console.WriteLine("---------------");

            return false;
        }
Exemplo n.º 5
0
        bool LocalEQHandler(CapsRequest req, CapsStage stage)
        {
            if (stage != CapsStage.Response) return true; // shortcircuit, so don't foward to sim
            Console.WriteLine(">> LocalEQHandler " + stage.ToString() + " to " + req.Info.URI);

            int length = req.Info.URI.Length;
            string key = req.Info.URI.Substring(length - 37, 36);
            //Console.WriteLine("       key " + key);
            // it comes back on the Response phase
            EventQueue _eq = Agent.GetEventQueue(key);
            if (_eq == null)
            {
                Console.WriteLine("[GRIDER]: Agent has no EQ??? Creating new one");
                _eq = new EventQueue();
            }
            else
            {
                Console.WriteLine("[GRIDER]: Found Event Queue for agent " + key);
            }

            if (_eq.Run(req) == null)
                Agent.RemoveEventQueue(key);

            //    req.Response = new OSD();

            return false;
        }
Exemplo n.º 6
0
 bool EventQueueGetHandler(CapsRequest req, CapsStage stage)
 {
     Console.WriteLine(">> EventQueuGet ");
     return false;
 }