private void SendRegionOffline(SceneInfo neighbor) { // Build the region/offline message OSDMap regionOffline = new OSDMap { { "region_id", OSD.FromUUID(m_scene.ID) } }; Uri regionOfflineCap; if (neighbor.TryGetCapability("region/offline", out regionOfflineCap)) { // Send the message try { UntrustedHttpWebRequest.PostToUntrustedUrl(regionOfflineCap, OSDParser.SerializeJsonString(regionOffline)); m_log.Debug(m_scene.Name + " sent region/offline to " + neighbor.Name); } catch (Exception ex) { m_log.Warn(m_scene.Name + " failed to send region/offline to " + neighbor.Name + ": " + ex.Message); } } else { m_log.Warn("No region/offline capability found for " + neighbor.Name + ", " + m_scene.Name + " is skipping it"); } }
private void SendChildUpdate(IScenePresence presence) { const float DEFAULT_DRAW_DISTANCE = 128.0f; // Build the template child_avatar/update message OSDMap childUpdate = new OSDMap(); childUpdate["agent_id"] = OSD.FromUUID(presence.ID); childUpdate["rotation"] = OSD.FromQuaternion(presence.SceneRotation); float drawDistance = DEFAULT_DRAW_DISTANCE; if (presence is LLAgent) { LLAgent agent = (LLAgent)presence; drawDistance = agent.DrawDistance; childUpdate["camera_center"] = OSD.FromVector3(agent.CameraPosition); childUpdate["camera_at"] = OSD.FromVector3(agent.CameraAtAxis); childUpdate["camera_left"] = OSD.FromVector3(agent.CameraLeftAxis); childUpdate["camera_up"] = OSD.FromVector3(agent.CameraUpAxis); } childUpdate["draw_distance"] = OSD.FromReal(drawDistance); // Get a list of neighbors to send this update to based on the draw distance SceneInfo[] neighbors = m_scene.GetNeighborsNear(m_scene.MinPosition + new Vector3d(presence.ScenePosition), drawDistance); for (int i = 0; i < neighbors.Length; i++) { SceneInfo neighbor = neighbors[i]; // Find the presence position relative to this neighbor Vector3 relativePosition = presence.ScenePosition - new Vector3(neighbor.MinPosition - presence.Scene.MinPosition); childUpdate["position"] = OSD.FromVector3(relativePosition); Uri childUpdateCap; if (neighbor.TryGetCapability("child_avatar/update", out childUpdateCap)) { try { // Send the message //m_log.Debug("Sending child agent update for " + presence.Name); string message = OSDParser.SerializeJsonString(childUpdate); UntrustedHttpWebRequest.PostToUntrustedUrl(childUpdateCap, message); } catch (Exception ex) { m_log.Warn("child_avatar/update from " + m_scene.Name + " to " + neighbor.Name + " for agent " + presence.Name + " failed: " + ex.Message); } } else { // This shouldn't happen since we check for the child_avatar/update capability // before adding this agent/neighbor pair to the queue throw new InvalidOperationException("child_avatar/update capability not found in SendChildUpdate handler"); } } }
private bool SendRezAvatarRequest(LLAgent agent, SceneInfo neighbor, bool isChild, out IPAddress simHost, out int simPort, out Uri seedCapability) { simHost = null; simPort = 0; seedCapability = null; Uri rezAvatarRequestCap; if (neighbor.TryGetCapability("rez_avatar/request", out rezAvatarRequestCap)) { string firstName, lastName; Util.GetFirstLastName(agent.Name, out firstName, out lastName); // Find the presence position relative to this neighbor Vector3 relativePosition = agent.ScenePosition - new Vector3(neighbor.MinPosition - m_scene.MinPosition); // Calculate the direction this agent is currently facing Vector3 lookAt = Vector3.UnitY * agent.RelativeRotation; // Create the template rez_avatar/request message OSDMap rezAvatarRequest = new OSDMap { { "agent_id", OSD.FromUUID(agent.ID) }, { "session_id", OSD.FromUUID(agent.SessionID) }, { "position", OSD.FromVector3(relativePosition) }, { "look_at", OSD.FromVector3(lookAt) }, { "velocity", OSD.FromVector3(agent.Velocity) }, { "child", OSD.FromBoolean(isChild) } }; OSDMap rezAvatarResponse = null; try { // Send the message and get a response rezAvatarResponse = OSDParser.Deserialize(UntrustedHttpWebRequest.PostToUntrustedUrl( rezAvatarRequestCap, OSDParser.SerializeJsonString(rezAvatarRequest))) as OSDMap; } catch { } if (rezAvatarResponse != null) { return(RezChildAgentReplyHandler(agent, rezAvatarResponse, out simHost, out simPort, out seedCapability)); } else { m_log.Warn(m_scene.Name + " failed to create a child agent on " + neighbor.Name + ", rez_avatar/request failed"); } } else { m_log.Warn(neighbor.Name + " does not have a rez_avatar/request capability"); } return(false); }
private void SendRegionOnline(SceneInfo neighbor) { // Build the region/online message uint regionX, regionY; GetRegionXY(m_scene.MinPosition, out regionX, out regionY); OSDMap regionOnline = new OSDMap { { "region_id", OSD.FromUUID(m_scene.ID) }, { "region_name", OSD.FromString(m_scene.Name) }, { "region_x", OSD.FromInteger(regionX) }, { "region_y", OSD.FromInteger(regionY) } }; // Put our public region seed capability into the message Uri publicSeedCap; if (m_scene.TryGetPublicCapability("public_region_seed_capability", out publicSeedCap)) { regionOnline["public_region_seed_capability"] = OSD.FromUri(publicSeedCap); } else { m_log.Warn("Registering scene " + m_scene.Name + " with neighbor " + neighbor.Name + " without a public seed capability"); } // Send the hello notification Uri regionOnlineCap; if (neighbor.TryGetCapability("region/online", out regionOnlineCap)) { try { UntrustedHttpWebRequest.PostToUntrustedUrl(regionOnlineCap, OSDParser.SerializeJsonString(regionOnline)); //m_log.Debug(scene.Name + " sent region/online to " + curScene.Name); } catch (Exception ex) { m_log.Warn(m_scene.Name + " failed to send region/online to " + neighbor.Name + ": " + ex.Message); } } else { m_log.Warn("No region/online capability found for " + neighbor.Name + ", " + m_scene.Name + " is skipping it"); } }
private bool SendRezAvatarRequest(LLAgent agent, SceneInfo neighbor, bool isChild, out IPAddress simHost, out int simPort, out Uri seedCapability) { simHost = null; simPort = 0; seedCapability = null; Uri rezAvatarRequestCap; if (neighbor.TryGetCapability("rez_avatar/request", out rezAvatarRequestCap)) { string firstName, lastName; Util.GetFirstLastName(agent.Name, out firstName, out lastName); // Find the presence position relative to this neighbor Vector3 relativePosition = agent.ScenePosition - new Vector3(neighbor.MinPosition - m_scene.MinPosition); // Calculate the direction this agent is currently facing Vector3 lookAt = Vector3.UnitY * agent.RelativeRotation; // Create the template rez_avatar/request message OSDMap rezAvatarRequest = new OSDMap { { "agent_id", OSD.FromUUID(agent.ID) }, { "session_id", OSD.FromUUID(agent.SessionID) }, { "position", OSD.FromVector3(relativePosition) }, { "look_at", OSD.FromVector3(lookAt) }, { "velocity", OSD.FromVector3(agent.Velocity) }, { "child", OSD.FromBoolean(isChild) } }; OSDMap rezAvatarResponse = null; try { // Send the message and get a response rezAvatarResponse = OSDParser.Deserialize(UntrustedHttpWebRequest.PostToUntrustedUrl( rezAvatarRequestCap, OSDParser.SerializeJsonString(rezAvatarRequest))) as OSDMap; } catch { } if (rezAvatarResponse != null) { return RezChildAgentReplyHandler(agent, rezAvatarResponse, out simHost, out simPort, out seedCapability); } else { m_log.Warn(m_scene.Name + " failed to create a child agent on " + neighbor.Name + ", rez_avatar/request failed"); } } else { m_log.Warn(neighbor.Name + " does not have a rez_avatar/request capability"); } return false; }
private void SendRegionOnline(SceneInfo neighbor) { // Build the region/online message uint regionX, regionY; GetRegionXY(m_scene.MinPosition, out regionX, out regionY); OSDMap regionOnline = new OSDMap { { "region_id", OSD.FromUUID(m_scene.ID) }, { "region_name", OSD.FromString(m_scene.Name) }, { "region_x", OSD.FromInteger(regionX) }, { "region_y", OSD.FromInteger(regionY) } }; // Put our public region seed capability into the message Uri publicSeedCap; if (m_scene.TryGetPublicCapability("public_region_seed_capability", out publicSeedCap)) regionOnline["public_region_seed_capability"] = OSD.FromUri(publicSeedCap); else m_log.Warn("Registering scene " + m_scene.Name + " with neighbor " + neighbor.Name + " without a public seed capability"); // Send the hello notification Uri regionOnlineCap; if (neighbor.TryGetCapability("region/online", out regionOnlineCap)) { try { UntrustedHttpWebRequest.PostToUntrustedUrl(regionOnlineCap, OSDParser.SerializeJsonString(regionOnline)); //m_log.Debug(scene.Name + " sent region/online to " + curScene.Name); } catch (Exception ex) { m_log.Warn(m_scene.Name + " failed to send region/online to " + neighbor.Name + ": " + ex.Message); } } else { m_log.Warn("No region/online capability found for " + neighbor.Name + ", " + m_scene.Name + " is skipping it"); } }