private void SeedRequestCompleteHandler(CapsClient client, OSD result, Exception error) { if (result != null && result.Type == OSDType.Map) { OSDMap respTable = (OSDMap)result; foreach (string cap in respTable.Keys) { _Caps[cap] = respTable[cap].AsUri(); } if (_Caps.ContainsKey("EventQueueGet")) { Logger.DebugLog("Starting event queue for " + Simulator.ToString(), Simulator.Client); _EventQueueCap = new EventQueueClient(_Caps["EventQueueGet"]); _EventQueueCap.OnConnected += EventQueueConnectedHandler; _EventQueueCap.OnEvent += EventQueueEventHandler; _EventQueueCap.Start(); } } else { // The initial CAPS connection failed, try again MakeSeedRequest(); } }
public override CmdResult ExecuteRequest(CmdRequest args) { int argsUsed; OpenMetaverse.Simulator CurSim = TryGetSim(args, out argsUsed) ?? Client.Network.CurrentSim; StringBuilder output = new StringBuilder(); output.AppendLine(CurSim.ToString()); output.Append("UUID: "); output.AppendLine(CurSim.ID.ToString()); output.Append("RegionID: "); output.AppendLine(CurSim.RegionID.ToString()); uint x, y; Utils.LongToUInts(CurSim.Handle, out x, out y); output.AppendLine(String.Format("Handle: {0} (X: {1} Y: {2})", CurSim.Handle, x, y)); output.Append("Access: "); output.AppendLine(CurSim.Access.ToString()); output.Append("Flags: "); output.AppendLine(CurSim.Flags.ToString()); output.Append("TerrainBase0: "); output.AppendLine(CurSim.TerrainBase0.ToString()); output.Append("TerrainBase1: "); output.AppendLine(CurSim.TerrainBase1.ToString()); output.Append("TerrainBase2: "); output.AppendLine(CurSim.TerrainBase2.ToString()); output.Append("TerrainBase3: "); output.AppendLine(CurSim.TerrainBase3.ToString()); output.Append("TerrainDetail0: "); output.AppendLine(CurSim.TerrainDetail0.ToString()); output.Append("TerrainDetail1: "); output.AppendLine(CurSim.TerrainDetail1.ToString()); output.Append("TerrainDetail2: "); output.AppendLine(CurSim.TerrainDetail2.ToString()); output.Append("TerrainDetail3: "); output.AppendLine(CurSim.TerrainDetail3.ToString()); output.Append("Water Height: "); output.AppendLine(CurSim.WaterHeight.ToString()); return(Success(output.ToString())); }
private void SeedRequestCompleteHandler(CapsClient client, OSD result, Exception error) { if (result != null && result.Type == OSDType.Map) { OSDMap respTable = (OSDMap)result; foreach (string cap in respTable.Keys) { _Caps[cap] = respTable[cap].AsUri(); } if (_Caps.ContainsKey("EventQueueGet")) { Logger.DebugLog("Starting event queue for " + Simulator.ToString(), Simulator.Client); _EventQueueCap = new EventQueueClient(_Caps["EventQueueGet"]); _EventQueueCap.OnConnected += EventQueueConnectedHandler; _EventQueueCap.OnEvent += EventQueueEventHandler; _EventQueueCap.Start(); } OnCapabilitiesReceived(Simulator); } else if ( error != null && error is WebException && ((WebException)error).Response != null && ((HttpWebResponse)((WebException)error).Response).StatusCode == HttpStatusCode.NotFound) { // 404 error Logger.Log("Seed capability returned a 404, capability system is aborting", Helpers.LogLevel.Error); } else { // The initial CAPS connection failed, try again MakeSeedRequest(); } }
private void Network_OnEventQueueRunning(Simulator simulator) { Logger.DebugLog("Event queue is running for " + simulator.ToString() + ", enabling uploads", Client); EnableUpload(); }
/// <summary> /// Handler for teleport Requests /// </summary> /// <param name="packet">Incoming TeleportHandler packet</param> /// <param name="simulator">Simulator sending teleport information</param> private void TeleportHandler(Packet packet, Simulator simulator) { bool finished = false; TeleportFlags flags = TeleportFlags.Default; if (packet.Type == PacketType.TeleportStart) { TeleportStartPacket start = (TeleportStartPacket)packet; teleportMessage = "Teleport started"; flags = (TeleportFlags)start.Info.TeleportFlags; teleportStat = TeleportStatus.Start; Logger.DebugLog("TeleportStart received, Flags: " + flags.ToString(), Client); } else if (packet.Type == PacketType.TeleportProgress) { TeleportProgressPacket progress = (TeleportProgressPacket)packet; teleportMessage = Helpers.FieldToUTF8String(progress.Info.Message); flags = (TeleportFlags)progress.Info.TeleportFlags; teleportStat = TeleportStatus.Progress; Logger.DebugLog("TeleportProgress received, Message: " + teleportMessage + ", Flags: " + flags.ToString(), Client); } else if (packet.Type == PacketType.TeleportFailed) { TeleportFailedPacket failed = (TeleportFailedPacket)packet; teleportMessage = Helpers.FieldToUTF8String(failed.Info.Reason); teleportStat = TeleportStatus.Failed; finished = true; Logger.DebugLog("TeleportFailed received, Reason: " + teleportMessage, Client); } else if (packet.Type == PacketType.TeleportFinish) { TeleportFinishPacket finish = (TeleportFinishPacket)packet; flags = (TeleportFlags)finish.Info.TeleportFlags; string seedcaps = Helpers.FieldToUTF8String(finish.Info.SeedCapability); finished = true; Logger.DebugLog("TeleportFinish received, Flags: " + flags.ToString(), Client); // Connect to the new sim Simulator newSimulator = Client.Network.Connect(new IPAddress(finish.Info.SimIP), finish.Info.SimPort, finish.Info.RegionHandle, true, seedcaps); if (newSimulator != null) { teleportMessage = "Teleport finished"; teleportStat = TeleportStatus.Finished; // Disconnect from the previous sim Client.Network.DisconnectSim(simulator, true); Logger.Log("Moved to new sim " + newSimulator.ToString(), Helpers.LogLevel.Info, Client); } else { teleportMessage = "Failed to connect to the new sim after a teleport"; teleportStat = TeleportStatus.Failed; // We're going to get disconnected now Logger.Log(teleportMessage, Helpers.LogLevel.Error, Client); } } else if (packet.Type == PacketType.TeleportCancel) { //TeleportCancelPacket cancel = (TeleportCancelPacket)packet; teleportMessage = "Cancelled"; teleportStat = TeleportStatus.Cancelled; finished = true; Logger.DebugLog("TeleportCancel received from " + simulator.ToString(), Client); } else if (packet.Type == PacketType.TeleportLocal) { TeleportLocalPacket local = (TeleportLocalPacket)packet; teleportMessage = "Teleport finished"; flags = (TeleportFlags)local.Info.TeleportFlags; teleportStat = TeleportStatus.Finished; relativePosition = local.Info.Position; Movement.Camera.LookDirection(local.Info.LookAt); // This field is apparently not used for anything //local.Info.LocationID; finished = true; Logger.DebugLog("TeleportLocal received, Flags: " + flags.ToString(), Client); } if (OnTeleport != null) { try { OnTeleport(teleportMessage, teleportStat, flags); } catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); } } if (finished) teleportEvent.Set(); }
private void RegionHandshakeHandler(Packet packet, Simulator simulator) { RegionHandshakePacket handshake = (RegionHandshakePacket)packet; simulator.ID = handshake.RegionInfo.CacheID; simulator.IsEstateManager = handshake.RegionInfo.IsEstateManager; simulator.Name = Utils.BytesToString(handshake.RegionInfo.SimName); simulator.SimOwner = handshake.RegionInfo.SimOwner; simulator.TerrainBase0 = handshake.RegionInfo.TerrainBase0; simulator.TerrainBase1 = handshake.RegionInfo.TerrainBase1; simulator.TerrainBase2 = handshake.RegionInfo.TerrainBase2; simulator.TerrainBase3 = handshake.RegionInfo.TerrainBase3; simulator.TerrainDetail0 = handshake.RegionInfo.TerrainDetail0; simulator.TerrainDetail1 = handshake.RegionInfo.TerrainDetail1; simulator.TerrainDetail2 = handshake.RegionInfo.TerrainDetail2; simulator.TerrainDetail3 = handshake.RegionInfo.TerrainDetail3; simulator.TerrainHeightRange00 = handshake.RegionInfo.TerrainHeightRange00; simulator.TerrainHeightRange01 = handshake.RegionInfo.TerrainHeightRange01; simulator.TerrainHeightRange10 = handshake.RegionInfo.TerrainHeightRange10; simulator.TerrainHeightRange11 = handshake.RegionInfo.TerrainHeightRange11; simulator.TerrainStartHeight00 = handshake.RegionInfo.TerrainStartHeight00; simulator.TerrainStartHeight01 = handshake.RegionInfo.TerrainStartHeight01; simulator.TerrainStartHeight10 = handshake.RegionInfo.TerrainStartHeight10; simulator.TerrainStartHeight11 = handshake.RegionInfo.TerrainStartHeight11; simulator.WaterHeight = handshake.RegionInfo.WaterHeight; simulator.Flags = (RegionFlags)handshake.RegionInfo.RegionFlags; simulator.BillableFactor = handshake.RegionInfo.BillableFactor; simulator.Access = (SimAccess)handshake.RegionInfo.SimAccess; Logger.Log("Received a region handshake for " + simulator.ToString(), Helpers.LogLevel.Info, Client); // Send a RegionHandshakeReply RegionHandshakeReplyPacket reply = new RegionHandshakeReplyPacket(); reply.AgentData.AgentID = Client.Self.AgentID; reply.AgentData.SessionID = Client.Self.SessionID; reply.RegionInfo.Flags = 0; SendPacket(reply, simulator); // We're officially connected to this sim simulator.connected = true; simulator.ConnectedEvent.Set(); }
private void ParcelOverlayHandler(Packet packet, Simulator simulator) { const int OVERLAY_COUNT = 4; ParcelOverlayPacket overlay = (ParcelOverlayPacket)packet; if (overlay.ParcelData.SequenceID >= 0 && overlay.ParcelData.SequenceID < OVERLAY_COUNT) { int length = overlay.ParcelData.Data.Length; Buffer.BlockCopy(overlay.ParcelData.Data, 0, simulator.ParcelOverlay, overlay.ParcelData.SequenceID * length, length); simulator.ParcelOverlaysReceived++; if (simulator.ParcelOverlaysReceived >= OVERLAY_COUNT) { // TODO: ParcelOverlaysReceived should become internal, and reset to zero every // time it hits four. Also need a callback here } } else { Logger.Log("Parcel overlay with sequence ID of " + overlay.ParcelData.SequenceID + " received from " + simulator.ToString(), Helpers.LogLevel.Warning, Client); } }