/// <summary> /// /// </summary> /// <param name="UserInfo"></param> /// <param name="Request"></param> public void RequestTeleport(NetworkInfo userInfo, TeleportLocationRequestPacket request) { if (Grid.ContainsKey(request.Info.RegionHandle)) { RegionInfo Region = Grid[request.Info.RegionHandle]; libsecondlife.Packets.TeleportStartPacket TeleportStart = new TeleportStartPacket(); TeleportStart.Info.TeleportFlags = 16; _server.SendPacket(TeleportStart, true, userInfo); libsecondlife.Packets.TeleportFinishPacket Teleport = new TeleportFinishPacket(); Teleport.Info.AgentID = userInfo.User.AgentID; Teleport.Info.RegionHandle = request.Info.RegionHandle; Teleport.Info.SimAccess = 13; Teleport.Info.SeedCapability = new byte[0]; System.Net.IPAddress oIP = System.Net.IPAddress.Parse(Region.IPAddress.Address); byte[] byteIP = oIP.GetAddressBytes(); uint ip = (uint)byteIP[3] << 24; ip += (uint)byteIP[2] << 16; ip += (uint)byteIP[1] << 8; ip += (uint)byteIP[0]; Teleport.Info.SimIP = ip; Teleport.Info.SimPort = Region.IPAddress.Port; Teleport.Info.LocationID = 4; Teleport.Info.TeleportFlags = 1 << 4;; _server.SendPacket(Teleport, true, userInfo); //this._agentManager.RemoveAgent(userInfo); } }
/// <summary> /// Process TeleportFinish from Event Queue and pass it onto our TeleportHandler /// </summary> /// <param name="capsKey">The message system key for this event</param> /// <param name="message">IMessage object containing decoded data from OSD</param> /// <param name="simulator">The simulator originating the event message</param> private void TeleportFinishEventHandler(string capsKey, IMessage message, Simulator simulator) { TeleportFinishMessage msg = (TeleportFinishMessage)message; TeleportFinishPacket p = new TeleportFinishPacket(); p.Info.AgentID = msg.AgentID; p.Info.LocationID = (uint)msg.LocationID; p.Info.RegionHandle = msg.RegionHandle; p.Info.SeedCapability = Utils.StringToBytes(msg.SeedCapability.ToString()); // FIXME: Check This p.Info.SimAccess = (byte)msg.SimAccess; p.Info.SimIP = Utils.IPToUInt(msg.IP); p.Info.SimPort = (ushort)msg.Port; p.Info.TeleportFlags = (uint)msg.Flags; // pass the packet onto the teleport handler TeleportHandler(this, new PacketReceivedEventArgs(p, simulator)); }
/// <summary> /// /// </summary> /// <param name="packet"></param> /// <param name="simulator"></param> private void TeleportHandler(Packet packet, Simulator simulator) { if (packet.Type == PacketType.TeleportStart) { TeleportMessage = "Teleport started"; TeleportStat = TeleportStatus.Start; if (OnBeginTeleport != null) { OnBeginTeleport(TeleportMessage, TeleportStat); } } else if (packet.Type == PacketType.TeleportProgress) { TeleportMessage = Helpers.FieldToString(((TeleportProgressPacket)packet).Info.Message); TeleportStat = TeleportStatus.Progress; if (OnBeginTeleport != null) { OnBeginTeleport(TeleportMessage, TeleportStat); } } else if (packet.Type == PacketType.TeleportFailed) { TeleportMessage = Helpers.FieldToString(((TeleportFailedPacket)packet).Info.Reason); TeleportStat = TeleportStatus.Failed; if (OnBeginTeleport != null) { OnBeginTeleport(TeleportMessage, TeleportStat); } OnBeginTeleport = null; } else if (packet.Type == PacketType.TeleportFinish) { TeleportFinishPacket finish = (TeleportFinishPacket)packet; // Connect to the new sim Simulator sim = Client.Network.Connect(new IPAddress((long)finish.Info.SimIP), finish.Info.SimPort, simulator.CircuitCode, true); if (sim != null) { TeleportMessage = "Teleport finished"; TeleportStat = TeleportStatus.Finished; // Move the avatar in to the new sim CompleteAgentMovementPacket move = new CompleteAgentMovementPacket(); move.AgentData.AgentID = Client.Network.AgentID; move.AgentData.SessionID = Client.Network.SessionID; move.AgentData.CircuitCode = simulator.CircuitCode; Client.Network.SendPacket((Packet)move); Client.DebugLog(move.ToString()); Client.Log("Moved to new sim " + Client.Network.CurrentSim.Region.Name + "(" + Client.Network.CurrentSim.IPEndPoint.ToString() + ")", Helpers.LogLevel.Info); if (OnBeginTeleport != null) { OnBeginTeleport(TeleportMessage, TeleportStat); } else { // Sleep a little while so we can collect parcel information System.Threading.Thread.Sleep(1000); } } else { TeleportMessage = "Failed to connect to the new sim after a teleport"; TeleportStat = TeleportStatus.Failed; Client.Log(TeleportMessage, Helpers.LogLevel.Warning); if (OnBeginTeleport != null) { OnBeginTeleport(TeleportMessage, TeleportStat); } } OnBeginTeleport = null; } }
/// <summary> /// Process TeleportFinish from Event Queue and pass it onto our TeleportHandler /// </summary> /// <param name="message"></param> /// <param name="llsd"></param> /// <param name="simulator"></param> private void TeleportFinishEventHandler(string message, LLSD llsd, Simulator simulator) { LLSDMap map = (LLSDMap)llsd; LLSDArray array = (LLSDArray)map["Info"]; for (int i = 0; i < array.Count; i++) { TeleportFinishPacket p = new TeleportFinishPacket(); LLSDMap data = (LLSDMap)array[i]; p.Info.AgentID = data["AgentID"].AsUUID(); p.Info.LocationID = Utils.BytesToUInt(data["LocationID"].AsBinary()); p.Info.RegionHandle = Utils.BytesToUInt64(data["RegionHandle"].AsBinary()); p.Info.SeedCapability = data["SeedCapability"].AsBinary(); p.Info.SimAccess = (byte)data["SimAccess"].AsInteger(); p.Info.SimIP = Utils.BytesToUInt(data["SimIP"].AsBinary()); p.Info.SimPort = (ushort)data["SimPort"].AsInteger(); p.Info.TeleportFlags = Utils.BytesToUInt(data["TeleportFlags"].AsBinary()); // pass the packet onto the teleport handler TeleportHandler(p, simulator); } }
private void EventQueueHandler(string message, object body) { if(message == "TeleportFinish") { Hashtable tpt = (Hashtable)body; Hashtable info = (Hashtable)tpt["Info"]; // FIXME: quick and dirty hack TeleportFinishPacket packet = new TeleportFinishPacket(); packet.Info.SimIP = CapToUInt32((byte[])info["SimIP"]); packet.Info.LocationID = CapToUInt32((byte[])info["LocationID"]); packet.Info.TeleportFlags = CapToUInt32((byte[])info["TeleportFlags"]); packet.Info.AgentID = (LLUUID)info["AgentID"]; packet.Info.RegionHandle = CapToUInt64((byte[])info["RegionHandle"]); packet.Info.SeedCapability = Helpers.StringToField((string)info["SeedCapability"]); packet.Info.SimPort = (ushort)(long)info["SimPort"]; packet.Info.SimAccess = (byte)(long)info["SimAccess"]; TeleportHandler(packet,Client.Network.CurrentSim); } }
/// <summary> /// /// </summary> /// <param name="UserInfo"></param> /// <param name="Request"></param> public void RequestTeleport(NetworkInfo userInfo, TeleportLocationRequestPacket request) { if(Grid.ContainsKey(request.Info.RegionHandle)) { RegionInfo Region = Grid[request.Info.RegionHandle]; libsecondlife.Packets.TeleportStartPacket TeleportStart = new TeleportStartPacket(); TeleportStart.Info.TeleportFlags = 16; _server.SendPacket(TeleportStart, true, userInfo); libsecondlife.Packets.TeleportFinishPacket Teleport = new TeleportFinishPacket(); Teleport.Info.AgentID = userInfo.User.AgentID; Teleport.Info.RegionHandle = request.Info.RegionHandle; Teleport.Info.SimAccess = 13; Teleport.Info.SeedCapability = new byte[0]; System.Net.IPAddress oIP = System.Net.IPAddress.Parse(Region.IPAddress.Address); byte[] byteIP = oIP.GetAddressBytes(); uint ip=(uint)byteIP[3]<<24; ip+=(uint)byteIP[2]<<16; ip+=(uint)byteIP[1]<<8; ip+=(uint)byteIP[0]; Teleport.Info.SimIP = ip; Teleport.Info.SimPort = Region.IPAddress.Port; Teleport.Info.LocationID = 4; Teleport.Info.TeleportFlags = 1 << 4;; _server.SendPacket(Teleport, true, userInfo); //this._agentManager.RemoveAgent(userInfo); } }
private void EventQueueHandler(string message, Hashtable body, Caps caps) { if (message == "TeleportFinish" && body.ContainsKey("Info")) { ArrayList infoList = (ArrayList)body["Info"]; Hashtable info = (Hashtable)infoList[0]; // Backwards compatibility hack TeleportFinishPacket packet = new TeleportFinishPacket(); packet.Info.SimIP = Helpers.BytesToUIntBig((byte[])info["SimIP"]); packet.Info.LocationID = Helpers.BytesToUInt((byte[])info["LocationID"]); packet.Info.TeleportFlags = Helpers.BytesToUInt((byte[])info["TeleportFlags"]); packet.Info.AgentID = (LLUUID)info["AgentID"]; packet.Info.RegionHandle = Helpers.BytesToUInt64((byte[])info["RegionHandle"]); packet.Info.SeedCapability = Helpers.StringToField((string)info["SeedCapability"]); packet.Info.SimPort = (ushort)(int)info["SimPort"]; packet.Info.SimAccess = (byte)(int)info["SimAccess"]; Client.DebugLog(String.Format( "Received a TeleportFinish event from {0}, SimIP: {1}, Location: {2}, RegionHandle: {3}", caps.Simulator.ToString(), packet.Info.SimIP, packet.Info.LocationID, packet.Info.RegionHandle)); TeleportHandler(packet, Client.Network.CurrentSim); } else if(message == "EstablishAgentCommunication" && Client.Settings.MULTIPLE_SIMS) { string ipAndPort = (string)body["sim-ip-and-port"]; string[] pieces = ipAndPort.Split(':'); IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse(pieces[0]), Convert.ToInt32(pieces[1])); Simulator sim = Client.Network.FindSimulator(endPoint); if(sim == null) { Client.Log("Got EstablishAgentCommunication for unknown sim " + ipAndPort, Helpers.LogLevel.Error); } else { Client.Log("Got EstablishAgentCommunication for sim " + ipAndPort + ", seed cap " + (string)body["seed-capability"], Helpers.LogLevel.Info); sim.setSeedCaps((string)body["seed-capability"]); } } else { Client.Log("Received unhandled event " + message + " in the EventQueueHandler", Helpers.LogLevel.Warning); } }