private bool FixupEventQueueGet(CapsRequest capReq, CapsStage stage) { //if (stage == CapsStage.Request) // return ReifyEventQueueGetRequest(capReq); if (stage != CapsStage.Response) return false; Console.WriteLine("HERE : " + stage.ToString()); OSDMap map = (OSDMap)capReq.Response; OSDArray array = (OSDArray)map["events"]; for (int i = 0; i < array.Count; i++) { OSDMap evt = (OSDMap)array[i]; string message = evt["message"].AsString(); OSDMap body = (OSDMap)evt["body"]; if (message == "TeleportFinish" || message == "CrossedRegion") { OSDMap info = null; if (message == "TeleportFinish") info = (OSDMap)(((OSDArray)body["Info"])[0]); else info = (OSDMap)(((OSDArray)body["RegionData"])[0]); byte[] bytes = info["SimIP"].AsBinary(); uint simIP = Utils.BytesToUInt(bytes); ushort simPort = (ushort)info["SimPort"].AsInteger(); string capsURL = info["SeedCapability"].AsString(); GenericCheck(ref simIP, ref simPort, ref capsURL, capReq.Info.Sim == activeCircuit); info["SeedCapability"] = OSD.FromString(capsURL); bytes[0] = (byte)(simIP % 256); bytes[1] = (byte)((simIP >> 8) % 256); bytes[2] = (byte)((simIP >> 16) % 256); bytes[3] = (byte)((simIP >> 24) % 256); info["SimIP"] = OSD.FromBinary(bytes); info["SimPort"] = OSD.FromInteger(simPort); } else if (message == "EnableSimulator") { OSDMap info = null; info = (OSDMap)(((OSDArray)body["SimulatorInfo"])[0]); byte[] bytes = info["IP"].AsBinary(); uint IP = Utils.BytesToUInt(bytes); ushort Port = (ushort)info["Port"].AsInteger(); string capsURL = null; GenericCheck(ref IP, ref Port, ref capsURL, capReq.Info.Sim == activeCircuit); bytes[0] = (byte)(IP % 256); bytes[1] = (byte)((IP >> 8) % 256); bytes[2] = (byte)((IP >> 16) % 256); bytes[3] = (byte)((IP >> 24) % 256); info["IP"] = OSD.FromBinary(bytes); info["Port"] = OSD.FromInteger(Port); } else if (message == "EstablishAgentCommunication") { string ipAndPort = body["sim-ip-and-port"].AsString(); string[] pieces = ipAndPort.Split(':'); byte[] bytes = IPAddress.Parse(pieces[0]).GetAddressBytes(); uint simIP = Utils.BytesToUInt(bytes); ushort simPort = (ushort)Convert.ToInt32(pieces[1]); string capsURL = body["seed-capability"].AsString(); #if DEBUG_CAPS Console.WriteLine("DEBUG: Got EstablishAgentCommunication for " + ipAndPort + " with seed cap " + capsURL); #endif GenericCheck(ref simIP, ref simPort, ref capsURL, false); body["seed-capability"] = OSD.FromString(capsURL); string ipport = String.Format("{0}:{1}", new IPAddress(simIP), simPort); body["sim-ip-and-port"] = OSD.FromString(ipport); #if DEBUG_CAPS Console.WriteLine("DEBUG: Modified EstablishAgentCommunication to " + body["sim-ip-and-port"].AsString() + " with seed cap " + capsURL); #endif } } return false; }
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; }
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; }
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; }