/// <summary> /// Process incoming avatar animations /// </summary> /// <param name="packet"></param> /// <param name="sim"></param> private void AvatarAnimationHandler(object sender, PacketReceivedEventArgs e) { var sim = e.Simulator; var packet = e.Packet; if (!IsMaster(sim)) return; AvatarAnimationPacket data = (AvatarAnimationPacket)packet; List<Animation> signaledAnimations = new List<Animation>(data.AnimationList.Length); for (int i = 0; i < data.AnimationList.Length; i++) { Animation animation = new Animation(); animation.AnimationID = data.AnimationList[i].AnimID; animation.AnimationSequence = data.AnimationList[i].AnimSequenceID; if (i < data.AnimationSourceList.Length) { animation.AnimationSourceObjectID = data.AnimationSourceList[i].ObjectID; } signaledAnimations.Add(animation); } Avatars_OnAvatarAnimation(this, new AvatarAnimationEventArgs(data.Sender.ID, signaledAnimations)); }
/// <summary> /// Logs the packet received for this client. /// </summary> /// <remarks> /// This handler assumes that packets are processed one at a time. /// </remarks> /// <param name="sender">Sender.</param> /// <param name="args">Arguments.</param> private void HandlePacket(object sender, PacketReceivedEventArgs args) { // Console.WriteLine( // "Received packet {0} from {1} for {2}", args.Packet.Type, args.Simulator.Name, m_client.Self.Name); lock (this) { if (!m_isLogging) return; m_logStreamWriter.WriteLine("Received: {0}", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss.fff")); try { m_logStreamWriter.WriteLine(PacketDecoder.PacketToString(args.Packet)); } catch (Exception e) { m_logStreamWriter.WriteLine("Failed to write decode of {0}, exception {1}", args.Packet.Type, e); } if (--m_packetsToLogRemaining <= 0) { m_client.Network.UnregisterCallback(PacketType.Default, HandlePacket); m_logStreamWriter.Close(); Console.WriteLine("Finished logging packets for {0}", m_client.Self.Name); m_isLogging = false; } } }
private void AgentDataUpdateHandler(object sender, PacketReceivedEventArgs e) { AgentDataUpdatePacket p = (AgentDataUpdatePacket)e.Packet; if (p.AgentData.AgentID == Client.Self.AgentID) { activeGroup = Utils.BytesToString(p.AgentData.GroupName) + " ( " + Utils.BytesToString(p.AgentData.GroupTitle) + " )"; GroupsEvent.Set(); } }
//custom handler for dealing with estate packets void estateUpdateHandle(object sender, PacketReceivedEventArgs e) { EstateOwnerMessagePacket message = (EstateOwnerMessagePacket)e.Packet; RegionFlags flag = (RegionFlags)(Utils.BytesToInt(message.ParamList[3].Parameter)); if((flag & RegionFlags.NoFly) != RegionFlags.None) feedback("nofly"); else feedback("fly"); }
protected void AttachedSoundHandler(object sender, PacketReceivedEventArgs e) { var simulator = e.Simulator; var packet = e.Packet; if (!MaintainSounds) return; if (!IsMaster(simulator)) return; AttachedSoundPacket sound = (AttachedSoundPacket)packet; Sound_OnAttachSound(this, new AttachedSoundEventArgs(simulator, sound.DataBlock.SoundID, sound.DataBlock.OwnerID, sound.DataBlock.ObjectID, sound.DataBlock.Gain, (SoundFlags) sound.DataBlock.Flags)); }
protected void AttachedSoundGainChangeHandler(object sender, PacketReceivedEventArgs e) { var simulator = e.Simulator; var packet = e.Packet; if (!MaintainSounds) return; if (!IsMaster(simulator)) return; AttachedSoundGainChangePacket change = (AttachedSoundGainChangePacket)packet; Sound_OnAttachSoundGainChange(this,new AttachedSoundGainChangeEventArgs(simulator,change.DataBlock.ObjectID, change.DataBlock.Gain)); }
protected void PreloadSoundHandler(object sender, PacketReceivedEventArgs e) { var simulator = e.Simulator; var packet = e.Packet; if (!MaintainSounds) return; if (!IsMaster(simulator)) return; PreloadSoundPacket preload = (PreloadSoundPacket)packet; foreach (PreloadSoundPacket.DataBlockBlock data in preload.DataBlock) { Sound_OnPreloadSound(this, new PreloadSoundEventArgs(simulator, data.SoundID, data.OwnerID, data.ObjectID)); } }
protected void SoundTriggerHandler(object sender, PacketReceivedEventArgs e) { var simulator = e.Simulator; var packet = e.Packet; if (!MaintainSounds) return; if (!IsMaster(simulator)) return; SoundTriggerPacket trigger = (SoundTriggerPacket)packet; Sound_OnSoundTrigger(this, new SoundTriggerEventArgs(simulator, trigger.SoundData.SoundID, trigger.SoundData.OwnerID, trigger.SoundData.ObjectID, trigger.SoundData.ParentID, trigger.SoundData.Gain, trigger.SoundData.Handle, trigger.SoundData.Position)); }
/// <summary>Process an incoming packet and raise the appropriate events</summary> /// <param name="sender">The sender</param> /// <param name="e">The EventArgs object containing the packet data</param> protected void ScriptSensorReplyHandler(object sender, PacketReceivedEventArgs e) { if (m_ScriptSensorReply != null) { Packet packet = e.Packet; ScriptSensorReplyPacket reply = (ScriptSensorReplyPacket)packet; for (int i = 0; i < reply.SensedData.Length; i++) { ScriptSensorReplyPacket.SensedDataBlock block = reply.SensedData[i]; ScriptSensorReplyPacket.RequesterBlock requestor = reply.Requester; OnScriptSensorReply(new ScriptSensorReplyEventArgs(requestor.SourceID, block.GroupID, Utils.BytesToString(block.Name), block.ObjectID, block.OwnerID, block.Position, block.Range, block.Rotation, (ScriptSensorTypeFlags)block.Type, block.Velocity)); } } }
/// <summary>Process an incoming packet and raise the appropriate events</summary> /// <param name="sender">The sender</param> /// <param name="e">The EventArgs object containing the packet data</param> protected void AlertMessageHandler(object sender, PacketReceivedEventArgs e) { if (m_AlertMessage != null) { Packet packet = e.Packet; AlertMessagePacket alert = (AlertMessagePacket)packet; OnAlertMessage(new AlertMessageEventArgs(Utils.BytesToString(alert.AlertData.Message))); } }
/// <summary>Process an incoming packet and raise the appropriate events</summary> /// <param name="sender">The sender</param> /// <param name="e">The EventArgs object containing the packet data</param> protected void MeanCollisionAlertHandler(object sender, PacketReceivedEventArgs e) { if (m_MeanCollision != null) { Packet packet = e.Packet; MeanCollisionAlertPacket collision = (MeanCollisionAlertPacket)packet; for (int i = 0; i < collision.MeanCollision.Length; i++) { MeanCollisionAlertPacket.MeanCollisionBlock block = collision.MeanCollision[i]; DateTime time = Utils.UnixTimeToDateTime(block.Time); MeanCollisionType type = (MeanCollisionType)block.Type; OnMeanCollision(new MeanCollisionEventArgs(type, block.Perp, block.Victim, block.Mag, time)); } } }
/// <summary>Process an incoming packet and raise the appropriate events</summary> /// <param name="sender">The sender</param> /// <param name="e">The EventArgs object containing the packet data</param> protected void TeleportHandler(object sender, PacketReceivedEventArgs e) { Packet packet = e.Packet; Simulator simulator = e.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 = Utils.BytesToString(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 = Utils.BytesToString(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 = Utils.BytesToString(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; 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 (m_Teleport != null) { OnTeleport(new TeleportEventArgs(teleportMessage, teleportStat, flags)); } if (finished) teleportEvent.Set(); }
/// <summary>Process an incoming packet and raise the appropriate events</summary> /// <param name="sender">The sender</param> /// <param name="e">The EventArgs object containing the packet data</param> protected void AgentDataUpdateHandler(object sender, PacketReceivedEventArgs e) { Packet packet = e.Packet; Simulator simulator = e.Simulator; AgentDataUpdatePacket p = (AgentDataUpdatePacket)packet; if (p.AgentData.AgentID == simulator.Client.Self.AgentID) { firstName = Utils.BytesToString(p.AgentData.FirstName); lastName = Utils.BytesToString(p.AgentData.LastName); activeGroup = p.AgentData.ActiveGroupID; activeGroupPowers = (GroupPowers)p.AgentData.GroupPowers; if (m_AgentData != null) { string groupTitle = Utils.BytesToString(p.AgentData.GroupTitle); string groupName = Utils.BytesToString(p.AgentData.GroupName); OnAgentData(new AgentDataReplyEventArgs(firstName, lastName, activeGroup, groupTitle, activeGroupPowers, groupName)); } } else { Logger.Log("Got an AgentDataUpdate packet for avatar " + p.AgentData.AgentID.ToString() + " instead of " + Client.Self.AgentID.ToString() + ", this shouldn't happen", Helpers.LogLevel.Error, Client); } }
/// <summary> /// Update client's Position, LookAt and region handle from incoming packet /// </summary> /// <param name="sender">The sender</param> /// <param name="e">The EventArgs object containing the packet data</param> /// <remarks>This occurs when after an avatar moves into a new sim</remarks> private void MovementCompleteHandler(object sender, PacketReceivedEventArgs e) { Packet packet = e.Packet; Simulator simulator = e.Simulator; AgentMovementCompletePacket movement = (AgentMovementCompletePacket)packet; relativePosition = movement.Data.Position; Movement.Camera.LookDirection(movement.Data.LookAt); simulator.Handle = movement.Data.RegionHandle; simulator.SimVersion = Utils.BytesToString(movement.SimData.ChannelVersion); }
/// <summary>Process an incoming packet and raise the appropriate events</summary> /// <param name="sender">The sender</param> /// <param name="e">The EventArgs object containing the packet data</param> protected void ConfirmXferPacketHandler(object sender, PacketReceivedEventArgs e) { ConfirmXferPacketPacket confirm = (ConfirmXferPacketPacket)e.Packet; // Building a new UUID every time an ACK is received for an upload is a horrible // thing, but this whole Xfer system is horrible UUID transferID = new UUID(confirm.XferID.ID); Transfer transfer; AssetUpload upload = null; if (Transfers.TryGetValue(transferID, out transfer)) { upload = (AssetUpload)transfer; //Client.DebugLog(String.Format("ACK for upload {0} of asset type {1} ({2}/{3})", // upload.AssetID.ToString(), upload.Type, upload.Transferred, upload.Size)); try { OnUploadProgress(new AssetUploadEventArgs(upload)); } catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Error, Client, ex); } if (upload.Transferred < upload.Size) SendNextUploadPacket(upload); } }
/// <summary> /// Handles Script Control changes when Script with permissions releases or takes a control /// </summary> /// <param name="sender">The sender</param> /// <param name="e">The EventArgs object containing the packet data</param> private void ScriptControlChangeHandler(object sender, PacketReceivedEventArgs e) { if (m_ScriptControl != null) { Packet packet = e.Packet; ScriptControlChangePacket change = (ScriptControlChangePacket)packet; for (int i = 0; i < change.Data.Length; i++) { OnScriptControlChange(new ScriptControlEventArgs((ScriptControlChange)change.Data[i].Controls, change.Data[i].PassToAgent, change.Data[i].TakeControls)); } } }
/// <summary> /// Used for parsing llLoadURL Dialogs /// </summary> /// <param name="sender">The sender</param> /// <param name="e">The EventArgs object containing the packet data</param> protected void LoadURLHandler(object sender, PacketReceivedEventArgs e) { if (m_LoadURL != null) { Packet packet = e.Packet; LoadURLPacket loadURL = (LoadURLPacket)packet; OnLoadURL(new LoadUrlEventArgs( Utils.BytesToString(loadURL.Data.ObjectName), loadURL.Data.ObjectID, loadURL.Data.OwnerID, loadURL.Data.OwnerIsGroup, Utils.BytesToString(loadURL.Data.Message), Utils.BytesToString(loadURL.Data.URL) )); } }
/// <summary>Process an incoming packet and raise the appropriate events</summary> /// <param name="sender">The sender</param> /// <param name="e">The EventArgs object containing the packet data</param> protected void AssetUploadCompleteHandler(object sender, PacketReceivedEventArgs e) { AssetUploadCompletePacket complete = (AssetUploadCompletePacket)e.Packet; // If we uploaded an asset in a single packet, RequestXferHandler() // will never be called so we need to set this here as well WaitingForUploadConfirm = false; if (m_AssetUploadedEvent != null) { bool found = false; KeyValuePair<UUID, Transfer> foundTransfer = new KeyValuePair<UUID, Transfer>(); // Xfer system sucks really really bad. Where is the damn XferID? lock (Transfers) { foreach (KeyValuePair<UUID, Transfer> transfer in Transfers) { if (transfer.Value.GetType() == typeof(AssetUpload)) { AssetUpload upload = (AssetUpload)transfer.Value; if ((upload).AssetID == complete.AssetBlock.UUID) { found = true; foundTransfer = transfer; upload.Success = complete.AssetBlock.Success; upload.Type = (AssetType)complete.AssetBlock.Type; break; } } } } if (found) { lock (Transfers) Transfers.Remove(foundTransfer.Key); try { OnAssetUploaded(new AssetUploadEventArgs((AssetUpload)foundTransfer.Value)); } catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Error, Client, ex); } } else { Logger.Log(String.Format( "Got an AssetUploadComplete on an unrecognized asset, AssetID: {0}, Type: {1}, Success: {2}", complete.AssetBlock.UUID, (AssetType)complete.AssetBlock.Type, complete.AssetBlock.Success), Helpers.LogLevel.Warning); } } }
/// <summary>Process an incoming packet and raise the appropriate events</summary> /// <param name="sender">The sender</param> /// <param name="e">The EventArgs object containing the packet data</param> protected void HealthHandler(object sender, PacketReceivedEventArgs e) { Packet packet = e.Packet; health = ((HealthMessagePacket)packet).HealthData.Health; }
/// <summary>Process an incoming packet and raise the appropriate events</summary> /// <param name="sender">The sender</param> /// <param name="e">The EventArgs object containing the packet data</param> protected void SendXferPacketHandler(object sender, PacketReceivedEventArgs e) { SendXferPacketPacket xfer = (SendXferPacketPacket)e.Packet; // Lame ulong to UUID conversion, please go away Xfer system UUID transferID = new UUID(xfer.XferID.ID); Transfer transfer; XferDownload download = null; if (Transfers.TryGetValue(transferID, out transfer)) { download = (XferDownload)transfer; // Apply a mask to get rid of the "end of transfer" bit uint packetNum = xfer.XferID.Packet & 0x0FFFFFFF; // Check for out of order packets, possibly indicating a resend if (packetNum != download.PacketNum) { if (packetNum == download.PacketNum - 1) { Logger.DebugLog("Resending Xfer download confirmation for packet " + packetNum, Client); SendConfirmXferPacket(download.XferID, packetNum); } else { Logger.Log("Out of order Xfer packet in a download, got " + packetNum + " expecting " + download.PacketNum, Helpers.LogLevel.Warning, Client); // Re-confirm the last packet we actually received SendConfirmXferPacket(download.XferID, download.PacketNum - 1); } return; } if (packetNum == 0) { // This is the first packet received in the download, the first four bytes are a size integer // in little endian ordering byte[] bytes = xfer.DataPacket.Data; download.Size = (bytes[0] + (bytes[1] << 8) + (bytes[2] << 16) + (bytes[3] << 24)); download.AssetData = new byte[download.Size]; Logger.DebugLog("Received first packet in an Xfer download of size " + download.Size); Buffer.BlockCopy(xfer.DataPacket.Data, 4, download.AssetData, 0, xfer.DataPacket.Data.Length - 4); download.Transferred += xfer.DataPacket.Data.Length - 4; } else { Buffer.BlockCopy(xfer.DataPacket.Data, 0, download.AssetData, 1000 * (int)packetNum, xfer.DataPacket.Data.Length); download.Transferred += xfer.DataPacket.Data.Length; } // Increment the packet number to the packet we are expecting next download.PacketNum++; // Confirm receiving this packet SendConfirmXferPacket(download.XferID, packetNum); if ((xfer.XferID.Packet & 0x80000000) != 0) { // This is the last packet in the transfer if (!String.IsNullOrEmpty(download.Filename)) Logger.DebugLog("Xfer download for asset " + download.Filename + " completed", Client); else Logger.DebugLog("Xfer download for asset " + download.VFileID.ToString() + " completed", Client); download.Success = true; lock (Transfers) Transfers.Remove(download.ID); try { OnXferReceived(new XferReceivedEventArgs(download)); } catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Error, Client, ex); } } } }
/// <summary>Process an incoming packet and raise the appropriate events</summary> /// <param name="sender">The sender</param> /// <param name="e">The EventArgs object containing the packet data</param> protected void MoneyBalanceReplyHandler(object sender, PacketReceivedEventArgs e) { Packet packet = e.Packet; if (packet.Type == PacketType.MoneyBalanceReply) { MoneyBalanceReplyPacket reply = (MoneyBalanceReplyPacket)packet; this.balance = reply.MoneyData.MoneyBalance; if (m_MoneyBalance != null) { OnMoneyBalanceReply(new MoneyBalanceReplyEventArgs(reply.MoneyData.TransactionID, reply.MoneyData.TransactionSuccess, reply.MoneyData.MoneyBalance, reply.MoneyData.SquareMetersCredit, reply.MoneyData.SquareMetersCommitted, Utils.BytesToString(reply.MoneyData.Description))); } } if (m_Balance != null) { OnBalance(new BalanceEventArgs(balance)); } }
/// <summary>Process an incoming packet and raise the appropriate events</summary> /// <param name="sender">The sender</param> /// <param name="e">The EventArgs object containing the packet data</param> protected void AbortXferHandler(object sender, PacketReceivedEventArgs e) { AbortXferPacket abort = (AbortXferPacket)e.Packet; XferDownload download = null; // Lame ulong to UUID conversion, please go away Xfer system UUID transferID = new UUID(abort.XferID.ID); lock (Transfers) { Transfer transfer; if (Transfers.TryGetValue(transferID, out transfer)) { download = (XferDownload)transfer; Transfers.Remove(transferID); } } if (download != null && m_XferReceivedEvent != null) { download.Success = false; download.Error = (TransferError)abort.XferID.Result; try { OnXferReceived(new XferReceivedEventArgs(download)); } catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Error, Client, ex); } } }
/// <summary>Process an incoming packet and raise the appropriate events</summary> /// <param name="sender">The sender</param> /// <param name="e">The EventArgs object containing the packet data</param> protected void AvatarAnimationHandler(object sender, PacketReceivedEventArgs e) { Packet packet = e.Packet; AvatarAnimationPacket animation = (AvatarAnimationPacket)packet; if (animation.Sender.ID == Client.Self.AgentID) { lock (SignaledAnimations.Dictionary) { // Reset the signaled animation list SignaledAnimations.Dictionary.Clear(); for (int i = 0; i < animation.AnimationList.Length; i++) { UUID animID = animation.AnimationList[i].AnimID; int sequenceID = animation.AnimationList[i].AnimSequenceID; // Add this animation to the list of currently signaled animations SignaledAnimations.Dictionary[animID] = sequenceID; if (i < animation.AnimationSourceList.Length) { // FIXME: The server tells us which objects triggered our animations, // we should store this info //animation.AnimationSourceList[i].ObjectID } if (i < animation.PhysicalAvatarEventList.Length) { // FIXME: What is this? } if (Client.Settings.SEND_AGENT_UPDATES) { // We have to manually tell the server to stop playing some animations if (animID == Animations.STANDUP || animID == Animations.PRE_JUMP || animID == Animations.LAND || animID == Animations.MEDIUM_LAND) { Movement.FinishAnim = true; Movement.SendUpdate(true); Movement.FinishAnim = false; } } } } } if (m_AnimationsChanged != null) { OnAnimationsChanged(new AnimationsChangedEventArgs(this.SignaledAnimations)); } }
/// <summary> /// Take an incoming ImprovedInstantMessage packet, auto-parse, and if /// OnInstantMessage is defined call that with the appropriate arguments /// </summary> /// <param name="sender">The sender</param> /// <param name="e">The EventArgs object containing the packet data</param> protected void InstantMessageHandler(object sender, PacketReceivedEventArgs e) { Packet packet = e.Packet; Simulator simulator = e.Simulator; if (packet.Type == PacketType.ImprovedInstantMessage) { ImprovedInstantMessagePacket im = (ImprovedInstantMessagePacket)packet; if (m_InstantMessage != null) { InstantMessage message; message.FromAgentID = im.AgentData.AgentID; message.FromAgentName = Utils.BytesToString(im.MessageBlock.FromAgentName); message.ToAgentID = im.MessageBlock.ToAgentID; message.ParentEstateID = im.MessageBlock.ParentEstateID; message.RegionID = im.MessageBlock.RegionID; message.Position = im.MessageBlock.Position; message.Dialog = (InstantMessageDialog)im.MessageBlock.Dialog; message.GroupIM = im.MessageBlock.FromGroup; message.IMSessionID = im.MessageBlock.ID; message.Timestamp = new DateTime(im.MessageBlock.Timestamp); message.Message = Utils.BytesToString(im.MessageBlock.Message); message.Offline = (InstantMessageOnline)im.MessageBlock.Offline; message.BinaryBucket = im.MessageBlock.BinaryBucket; OnInstantMessage(new InstantMessageEventArgs(message, simulator)); } } }
/// <summary>Process an incoming packet and raise the appropriate events</summary> /// <param name="sender">The sender</param> /// <param name="e">The EventArgs object containing the packet data</param> /// <remarks>This packet is now being sent via the EventQueue</remarks> protected void CrossedRegionHandler(object sender, PacketReceivedEventArgs e) { Packet packet = e.Packet; CrossedRegionPacket crossing = (CrossedRegionPacket)packet; string seedCap = Utils.BytesToString(crossing.RegionData.SeedCapability); IPEndPoint endPoint = new IPEndPoint(crossing.RegionData.SimIP, crossing.RegionData.SimPort); Logger.DebugLog("Crossed in to new region area, attempting to connect to " + endPoint.ToString(), Client); Simulator oldSim = Client.Network.CurrentSim; Simulator newSim = Client.Network.Connect(endPoint, crossing.RegionData.RegionHandle, true, seedCap); if (newSim != null) { Logger.Log("Finished crossing over in to region " + newSim.ToString(), Helpers.LogLevel.Info, Client); if (m_RegionCrossed != null) { OnRegionCrossed(new RegionCrossedEventArgs(oldSim, newSim)); } } else { // The old simulator will (poorly) handle our movement still, so the connection isn't // completely shot yet Logger.Log("Failed to connect to new region " + endPoint.ToString() + " after crossing over", Helpers.LogLevel.Warning, Client); } }
/// <summary> /// Take an incoming Chat packet, auto-parse, and if OnChat is defined call /// that with the appropriate arguments. /// </summary> /// <param name="sender">The sender</param> /// <param name="e">The EventArgs object containing the packet data</param> protected void ChatHandler(object sender, PacketReceivedEventArgs e) { if (m_Chat != null) { Packet packet = e.Packet; ChatFromSimulatorPacket chat = (ChatFromSimulatorPacket)packet; OnChat(new ChatEventArgs(e.Simulator, Utils.BytesToString(chat.ChatData.Message), (ChatAudibleLevel)chat.ChatData.Audible, (ChatType)chat.ChatData.ChatType, (ChatSourceType)chat.ChatData.SourceType, Utils.BytesToString(chat.ChatData.FromName), chat.ChatData.SourceID, chat.ChatData.OwnerID, chat.ChatData.Position)); } }
/// <summary>Process an incoming packet and raise the appropriate events</summary> /// <param name="sender">The sender</param> /// <param name="e">The EventArgs object containing the packet data</param> protected void CameraConstraintHandler(object sender, PacketReceivedEventArgs e) { if (m_CameraConstraint != null) { Packet packet = e.Packet; CameraConstraintPacket camera = (CameraConstraintPacket)packet; OnCameraConstraint(new CameraConstraintEventArgs(camera.CameraCollidePlane.Plane)); } }
/// <summary> /// Used for parsing llDialogs /// </summary> /// <param name="sender">The sender</param> /// <param name="e">The EventArgs object containing the packet data</param> protected void ScriptDialogHandler(object sender, PacketReceivedEventArgs e) { if (m_ScriptDialog != null) { Packet packet = e.Packet; ScriptDialogPacket dialog = (ScriptDialogPacket)packet; List<string> buttons = new List<string>(); foreach (ScriptDialogPacket.ButtonsBlock button in dialog.Buttons) { buttons.Add(Utils.BytesToString(button.ButtonLabel)); } OnScriptDialog(new ScriptDialogEventArgs(Utils.BytesToString(dialog.Data.Message), Utils.BytesToString(dialog.Data.ObjectName), dialog.Data.ImageID, dialog.Data.ObjectID, Utils.BytesToString(dialog.Data.FirstName), Utils.BytesToString(dialog.Data.LastName), dialog.Data.ChatChannel, buttons)); } }
/// <summary>Process an incoming packet and raise the appropriate events</summary> /// <param name="sender">The sender</param> /// <param name="e">The EventArgs object containing the packet data</param> protected void AvatarSitResponseHandler(object sender, PacketReceivedEventArgs e) { if (m_AvatarSitResponse != null) { Packet packet = e.Packet; AvatarSitResponsePacket sit = (AvatarSitResponsePacket)packet; OnAvatarSitResponse(new AvatarSitResponseEventArgs(sit.SitObject.ID, sit.SitTransform.AutoPilot, sit.SitTransform.CameraAtOffset, sit.SitTransform.CameraEyeOffset, sit.SitTransform.ForceMouselook, sit.SitTransform.SitPosition, sit.SitTransform.SitRotation)); } }
/// <summary> /// Used for parsing llRequestPermissions dialogs /// </summary> /// <param name="sender">The sender</param> /// <param name="e">The EventArgs object containing the packet data</param> protected void ScriptQuestionHandler(object sender, PacketReceivedEventArgs e) { if (m_ScriptQuestion != null) { Packet packet = e.Packet; Simulator simulator = e.Simulator; ScriptQuestionPacket question = (ScriptQuestionPacket)packet; OnScriptQuestion(new ScriptQuestionEventArgs(simulator, question.Data.TaskID, question.Data.ItemID, Utils.BytesToString(question.Data.ObjectName), Utils.BytesToString(question.Data.ObjectOwner), (ScriptPermission)question.Data.Questions)); } }