private void ProcessAnimationsPacket(Packet packet, Simulator simulator) { if (!(packet is AvatarAnimationPacket)) return; AvatarAnimationPacket animation = (AvatarAnimationPacket)packet; SimData simData; if (!Ox.DataStore.World.SimCollection.TryGet(simulator.ID.ToString(), out simData)) return; ObjectData objectData; if (!simData.TryGet(animation.Sender.ID.ToString(), out objectData)) return; if (!(objectData is AvatarData)) return; AvatarData avatarData = objectData as AvatarData; List<AvatarData.Animation> anims = new List<AvatarData.Animation>(); foreach (AvatarAnimationPacket.AnimationListBlock block in animation.AnimationList) anims.Add(new AvatarData.Animation(block.AnimID.ToString(), block.AnimSequenceID)); avatarData.UpdateAnimation(anims.ToArray()); string msg = JsonUtil.SerializeMessage(JsonType.ObjectUpdated, new JsonObjectUpdated( simulator.ID.ToString(), animation.Sender.ID.ToString(), (int)JsonObjectUpdated.PrimType.Avatar, (int)JsonObjectUpdated.Type.UpdateAnimation )); Ox.EventFire(msg, true); }
public void SendPacket(Packet packet, Simulator sim) { if (OnPacketSent != null) { OnPacketSent(packet, sim); } }
private void AgentDataUpdateHandler(Packet packet, Simulator sim) { AgentDataUpdatePacket p = (AgentDataUpdatePacket)packet; if (p.AgentData.AgentID == Client.Self.AgentID) { activeGroup = Helpers.FieldToUTF8String(p.AgentData.GroupName) + " ( " + Helpers.FieldToUTF8String(p.AgentData.GroupTitle) + " )"; GroupsEvent.Set(); } }
private void AgentDataUpdateHandler(Packet packet, Simulator sim) { AgentDataUpdatePacket p = (AgentDataUpdatePacket)packet; if (p.AgentData.AgentID == Client.Self.AgentID) { activeGroup = Utils.BytesToString(p.AgentData.GroupName) + " ( " + Utils.BytesToString(p.AgentData.GroupTitle) + " )"; GroupsEvent.Set(); } }
void LogoutRequestHandler(Packet packet, Agent agent) { LogoutRequestPacket request = (LogoutRequestPacket)packet; LogoutReplyPacket reply = new LogoutReplyPacket(); reply.AgentData.AgentID = agent.AgentID; reply.AgentData.SessionID = agent.SessionID; reply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1]; reply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock(); reply.InventoryData[0].ItemID = UUID.Zero; lock (server.Agents) { if (server.Agents.ContainsKey(agent.Address)) { KillObjectPacket kill = new KillObjectPacket(); kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); kill.ObjectData[0].ID = agent.Avatar.LocalID; server.Agents.Remove(agent.Address); foreach (Agent recipient in server.Agents.Values) recipient.SendPacket(kill); } } }
void UseCircuitCodeHandler(Packet packet, Agent agent) { RegionHandshakePacket handshake = new RegionHandshakePacket(); handshake.RegionInfo.BillableFactor = 0f; handshake.RegionInfo.CacheID = UUID.Random(); handshake.RegionInfo.IsEstateManager = false; handshake.RegionInfo.RegionFlags = 1; handshake.RegionInfo.SimOwner = UUID.Random(); handshake.RegionInfo.SimAccess = 1; handshake.RegionInfo.SimName = Utils.StringToBytes("Simian"); handshake.RegionInfo.WaterHeight = 20.0f; handshake.RegionInfo.TerrainBase0 = UUID.Zero; handshake.RegionInfo.TerrainBase1 = UUID.Zero; handshake.RegionInfo.TerrainBase2 = UUID.Zero; handshake.RegionInfo.TerrainBase3 = UUID.Zero; handshake.RegionInfo.TerrainDetail0 = UUID.Zero; handshake.RegionInfo.TerrainDetail1 = UUID.Zero; handshake.RegionInfo.TerrainDetail2 = UUID.Zero; handshake.RegionInfo.TerrainDetail3 = UUID.Zero; handshake.RegionInfo.TerrainHeightRange00 = 0f; handshake.RegionInfo.TerrainHeightRange01 = 20f; handshake.RegionInfo.TerrainHeightRange10 = 0f; handshake.RegionInfo.TerrainHeightRange11 = 20f; handshake.RegionInfo.TerrainStartHeight00 = 0f; handshake.RegionInfo.TerrainStartHeight01 = 40f; handshake.RegionInfo.TerrainStartHeight10 = 0f; handshake.RegionInfo.TerrainStartHeight11 = 40f; handshake.RegionInfo2.RegionID = UUID.Random(); agent.SendPacket(handshake); }
public void SendPacket(Packet packet) { if (OnPacketSent != null) { OnPacketSent(packet, CurrentSim); } }
void AssetUploadRequestHandler(Packet packet, Agent agent) { AssetUploadRequestPacket request = (AssetUploadRequestPacket)packet; UUID assetID = UUID.Combine(request.AssetBlock.TransactionID, agent.SecureSessionID); // Check if the asset is small enough to fit in a single packet if (request.AssetBlock.AssetData.Length != 0) { // Create a new asset from the completed upload Asset asset = CreateAsset((AssetType)request.AssetBlock.Type, assetID, request.AssetBlock.AssetData); if (asset == null) { Logger.Log("Failed to create asset from uploaded data", Helpers.LogLevel.Warning); return; } Logger.DebugLog(String.Format("Storing uploaded asset {0} ({1})", assetID, asset.AssetType)); asset.Temporary = (request.AssetBlock.Tempfile | request.AssetBlock.StoreLocal); // Store the asset scene.Server.Assets.StoreAsset(asset); // Send a success response AssetUploadCompletePacket complete = new AssetUploadCompletePacket(); complete.AssetBlock.Success = true; complete.AssetBlock.Type = request.AssetBlock.Type; complete.AssetBlock.UUID = assetID; scene.UDP.SendPacket(agent.ID, complete, PacketCategory.Inventory); } else { // Create a new (empty) asset for the upload Asset asset = CreateAsset((AssetType)request.AssetBlock.Type, assetID, null); if (asset == null) { Logger.Log("Failed to create asset from uploaded data", Helpers.LogLevel.Warning); return; } Logger.DebugLog(String.Format("Starting upload for {0} ({1})", assetID, asset.AssetType)); asset.Temporary = (request.AssetBlock.Tempfile | request.AssetBlock.StoreLocal); RequestXferPacket xfer = new RequestXferPacket(); xfer.XferID.DeleteOnCompletion = request.AssetBlock.Tempfile; xfer.XferID.FilePath = 0; xfer.XferID.Filename = Utils.EmptyBytes; xfer.XferID.ID = request.AssetBlock.TransactionID.GetULong(); xfer.XferID.UseBigPackets = false; xfer.XferID.VFileID = asset.AssetID; xfer.XferID.VFileType = request.AssetBlock.Type; // Add this asset to the current upload list lock (CurrentUploads) CurrentUploads[xfer.XferID.ID] = asset; scene.UDP.SendPacket(agent.ID, xfer, PacketCategory.Inventory); } }
/// <summary> /// Fire the events registered for this packet type asynchronously /// </summary> /// <param name="packetType">Incoming packet type</param> /// <param name="packet">Incoming packet</param> /// <param name="agent">Agent this packet was received from</param> internal void BeginRaiseEvent(PacketType packetType, Packet packet, Agent agent) { UDPServer.PacketCallback callback; PacketCallbackWrapper wrapper; // Default handler first, if one exists if (_EventTable.TryGetValue(PacketType.Default, out callback)) { if (callback != null) { wrapper.Callback = callback; wrapper.Packet = packet; wrapper.Agent = agent; ThreadPool.QueueUserWorkItem(_ThreadPoolCallback, wrapper); } } if (_EventTable.TryGetValue(packetType, out callback)) { if (callback != null) { wrapper.Callback = callback; wrapper.Packet = packet; wrapper.Agent = agent; ThreadPool.QueueUserWorkItem(_ThreadPoolCallback, wrapper); return; } } if (packetType != PacketType.Default && packetType != PacketType.PacketAck) { Logger.DebugLog("No handler registered for packet event " + packetType); } }
public void AvatarAnimationHandler(OpenMetaverse.Packets.Packet packet, Simulator sim) { // When animations for any avatar are received put them in the AvatarAnimations dictionary // in this module. They should be processed and deleted inbetween frames in the main frame loop // or deleted when an avatar is deleted from the scene. AvatarAnimationPacket animation = (AvatarAnimationPacket)packet; UUID avatarID = animation.Sender.ID; List <UUID> currentAnims = new List <UUID>(); for (int i = 0; i < animation.AnimationList.Length; i++) { currentAnims.Add(animation.AnimationList[i].AnimID); } lock (AvatarAnimations) { if (AvatarAnimations.ContainsKey(avatarID)) { AvatarAnimations[avatarID] = currentAnims; } else { AvatarAnimations.Add(avatarID, currentAnims); } } }
void AvatarPropertiesRequestHandler(Packet packet, Agent agent) { AvatarPropertiesRequestPacket request = (AvatarPropertiesRequestPacket)packet; lock (Server.Agents) { foreach (Agent agt in Server.Agents.Values) { if (agent.AgentID == request.AgentData.AvatarID) { AvatarPropertiesReplyPacket reply = new AvatarPropertiesReplyPacket(); reply.AgentData.AgentID = agt.AgentID; reply.AgentData.AvatarID = request.AgentData.AvatarID; reply.PropertiesData.AboutText = Utils.StringToBytes("Profile info unavailable"); reply.PropertiesData.BornOn = Utils.StringToBytes("Unknown"); reply.PropertiesData.CharterMember = Utils.StringToBytes("Test User"); reply.PropertiesData.FLAboutText = Utils.StringToBytes("First life info unavailable"); reply.PropertiesData.Flags = 0; //TODO: at least generate static image uuids based on name. //this will prevent re-caching the default image for the same av name. reply.PropertiesData.FLImageID = agent.AgentID; //temporary hack reply.PropertiesData.ImageID = agent.AgentID; //temporary hack reply.PropertiesData.PartnerID = UUID.Zero; reply.PropertiesData.ProfileURL = Utils.StringToBytes(String.Empty); agent.SendPacket(reply); break; } } } }
private Packet Dialogs(Packet packet, IPEndPoint sim) { lock (recSeq) { if (!recSeq.Contains(packet.Header.Sequence)) { recSeq.Add(packet.Header.Sequence); if (recSeq.Count > 200) { recSeq.Clear(); } if (form.getCheckDiag()) { ScriptDialogPacket s = (ScriptDialogPacket)packet; lock (lastDialogs) { lastDialogs.Add(new diags((ScriptDialogPacket)packet)); if (lastDialogs.Count > 4) { lastDialogs.RemoveAt(0); } } List<UUID> whos = new List<UUID>(); lock (lastDialogs) { //proxy.writethis("new", ConsoleColor.Black, ConsoleColor.Blue); foreach (diags d in lastDialogs) { ScriptDialogPacket p = d.s; UUID who = p.Data.ObjectID; if (!whos.Contains(who)) whos.Add(who); //proxy.writethis(d.ToString(), ConsoleColor.Black, ConsoleColor.Cyan); } } if (lastDialogs.Count == 4) { TimeSpan duration = lastDialogs[3].time - lastDialogs[0].time; //proxy.writethis(durationToString(), ConsoleColor.Black, ConsoleColor.DarkCyan); if (duration.TotalMilliseconds < 400) { form.textBox1.Text += "DD"; //proxy.writeinthis("DD", ConsoleColor.Black, ConsoleColor.Red); return null; } } } } else return null; } return packet; }
public override void InPacket(uint circuitCode, Packet packet) { base.InPacket(circuitCode, packet); if (m_packetsReceived.ContainsKey(packet.Type)) m_packetsReceived[packet.Type]++; else m_packetsReceived[packet.Type] = 1; }
public Packet disbale(Packet p, IPEndPoint sim) { if (form.getChecked()) { string f = Utils.BytesToString(((RequestXferPacket)p).XferID.Filename); if (f.Contains(".db2") || f.Contains(".inv")) return null; } return p; }
public Packet ve(Packet p, IPEndPoint sim) { foreach(ViewerEffectPacket.EffectBlock b in ((ViewerEffectPacket)p).Effect) { if (b.Type == (byte)EffectType.AnimalControls && form.checkBox16animla.Checked) { form.textBox16animal.Text += b.ToString(); }else if (b.Type == (byte)EffectType.AnimationObject && form.checkBox15animation.Checked) { form.textBox15animat.Text += b.ToString(); }else if (b.Type == (byte)EffectType.Beam && form.checkBox14beam.Checked) { form.textBox14beam.Text += b.ToString(); }else if (b.Type == (byte)EffectType.Cloth && form.checkBox1cloth.Checked) { form.textBox1cloth.Text += b.ToString(); }else if (b.Type == (byte)EffectType.Connector && form.checkBox2connector.Checked) { form.textBox2connecotr.Text += b.ToString(); }else if (b.Type == (byte)EffectType.Edit && form.checkBox3edit.Checked) { form.textBox3edit.Text += b.ToString(); }else if (b.Type == (byte)EffectType.FlexibleObject && form.checkBox4flexble.Checked) { form.textBox4flexable.Text += b.ToString(); }else if (b.Type == (byte)EffectType.Glow && form.checkBox5glow.Checked) { form.textBox5glow.Text += b.ToString(); }else if (b.Type == (byte)EffectType.Icon && form.checkBox6icon.Checked) { form.textBox6icon.Text += b.ToString(); }else if (b.Type == (byte)EffectType.LookAt && form.checkBox7lookat.Checked) { form.textBox7lookat.Text += b.ToString(); }else if (b.Type == (byte)EffectType.Point && form.checkBox8point.Checked) { form.textBox8point.Text += b.ToString(); }else if (b.Type == (byte)EffectType.PointAt && form.checkBox9pointat.Checked) { form.textBox9pointat.Text += b.ToString(); }else if (b.Type == (byte)EffectType.Sphere && form.checkBox10sphere.Checked) { form.textBox10sphere.Text += b.ToString(); }else if (b.Type == (byte)EffectType.Spiral && form.checkBox11spiral.Checked) { form.textBox11spiral.Text += b.ToString(); }else if (b.Type == (byte)EffectType.Text && form.checkBox12text.Checked) { form.textBox12text.Text += b.ToString(); }else if (b.Type == (byte)EffectType.Trail && form.checkBox13trail.Checked) { form.textBox13trail.Text += b.ToString(); } } return p; }
public Packet sitp(Packet p, IPEndPoint sim) { if (form.checkBox1.Checked) { return null; } return p; }
void StartPingCheckHandler(Packet packet, Agent agent) { StartPingCheckPacket start = (StartPingCheckPacket)packet; CompletePingCheckPacket complete = new CompletePingCheckPacket(); complete.Header.Reliable = false; complete.PingID.PingID = start.PingID.PingID; agent.SendPacket(complete); }
/// <summary> /// Default constructor /// </summary> /// <param name="client">Reference to the client this packet is destined for</param> /// <param name="buffer">Serialized packet data. If the flags or sequence number /// need to be updated, they will be injected directly into this binary buffer</param> /// <param name="category">Throttling category for this packet</param> /// <param name="resendMethod">The delegate to be called if this packet is determined to be unacknowledged</param> /// <param name="finishedMethod">The delegate to be called when this packet is sent</param> public OutgoingPacket(LLUDPClient client, UDPPacketBuffer buffer, ThrottleOutPacketType category, UnackedPacketMethod resendMethod, UnackedPacketMethod finishedMethod, Packet packet) { Client = client; Buffer = buffer; Category = category; UnackedMethod = resendMethod; FinishedMethod = finishedMethod; Packet = packet; }
/// <summary> /// Turn a packet into an array of bytes. If necessary zerocde it. The returned array will be the correct length. /// </summary> /// <param name="packet">The packet to encode</param> protected byte[] GetBytes(OpenMetaverse.Packets.Packet packet) { byte[] bytes = packet.ToBytes(); int length = bytes.Length; if (packet.Header.Zerocoded) { byte[] zerod = new byte[8192]; length = Helpers.ZeroEncode(bytes, bytes.Length, zerod); bytes = zerod.Take(length).ToArray(); } return(bytes); }
void RequestImageHandler(Packet packet, Agent agent) { RequestImagePacket request = (RequestImagePacket)packet; for (int i = 0; i < request.RequestImage.Length; i++) { RequestImagePacket.RequestImageBlock block = request.RequestImage[i]; ImageDownload download; bool downloadFound = currentDownloads.TryGetValue(block.Image, out download); if (downloadFound) { lock (download) { if (block.DiscardLevel == -1 && block.DownloadPriority == 0.0f) Logger.DebugLog(String.Format("Image download {0} is aborting", block.Image)); // Update download download.Update(block.DiscardLevel, block.DownloadPriority, (int)block.Packet); } } else if (block.DiscardLevel == -1 && block.DownloadPriority == 0.0f) { // Aborting a download we are not tracking, this may be in the pipeline Pipeline.AbortDownload(block.Image); } else { bool bake = ((ImageType)block.Type == ImageType.Baked); // New download, check if we have this image Asset asset; if (server.Assets.TryGetAsset(block.Image, out asset) && asset is AssetTexture) { SendTexture(agent, (AssetTexture)asset, block.DiscardLevel, (int)block.Packet, block.DownloadPriority); } else { // We don't have this texture, add it to the download queue and see if the bot can get it for us download = new ImageDownload(null, agent, block.DiscardLevel, block.DownloadPriority, (int)block.Packet); lock (currentDownloads) currentDownloads[block.Image] = download; Pipeline.RequestTexture(block.Image, (ImageType)block.Type); } } } }
void AgentUpdateHandler(Packet packet, Agent agent) { AgentUpdatePacket update = (AgentUpdatePacket)packet; // Don't use the local physics to update the master agent if (agent != periscope.MasterAgent) { agent.Avatar.Rotation = update.AgentData.BodyRotation; agent.ControlFlags = (AgentManager.ControlFlags)update.AgentData.ControlFlags; agent.Avatar.PrimData.State = update.AgentData.State; // FIXME: Are these two different state variables? agent.Flags = (PrimFlags)update.AgentData.Flags; } ObjectUpdatePacket fullUpdate = SimulationObject.BuildFullUpdate(agent.Avatar, server.RegionHandle, agent.Flags); server.UDP.BroadcastPacket(fullUpdate, PacketCategory.State); }
private Packet InDisableSimulatorHandler(Packet packet, IPEndPoint sim) { string simIP = sim.ToString(); if (SharedInfo.Aux_Simulators.ContainsKey(simIP)) { if (SharedInfo.Aux_Simulators[simIP].Avatars.Count > 0) { lock (SharedInfo.Aux_Simulators[sim.ToString()].Avatars) { foreach (KeyValuePair<UUID, PubComb.Aux_Avatar> UUIDandAvatar in SharedInfo.Aux_Simulators[simIP].Avatars) { form.RemoveAvatar(UUIDandAvatar.Value); } } } SharedInfo.Aux_Simulators.Remove(simIP); } return packet; }
void AgentWearablesRequestHandler(Packet packet, Agent agent) { AgentWearablesUpdatePacket update = new AgentWearablesUpdatePacket(); update.AgentData.AgentID = agent.AgentID; update.AgentData.SessionID = agent.SessionID; // Technically this should be per-agent, but if the only requirement is that it // increments this is easier update.AgentData.SerialNum = (uint)Interlocked.Increment(ref currentWearablesSerialNum); update.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[4]; for (int i = 0; i < 4; i++) { update.WearableData[i] = new AgentWearablesUpdatePacket.WearableDataBlock(); update.WearableData[i].AssetID = UUID.Zero; update.WearableData[i].ItemID = UUID.Zero; update.WearableData[i].WearableType = 42; // HACK } agent.SendPacket(update); }
void AbortXferHandler(Packet packet, Agent agent) { AbortXferPacket abort = (AbortXferPacket)packet; lock (CurrentUploads) { if (CurrentUploads.ContainsKey(abort.XferID.ID)) { Logger.DebugLog(String.Format("Aborting Xfer {0}, result: {1}", abort.XferID.ID, (TransferError)abort.XferID.Result)); CurrentUploads.Remove(abort.XferID.ID); } else { Logger.DebugLog(String.Format("Received an AbortXfer for an unknown xfer {0}", abort.XferID.ID)); } } }
void RequestImageHandler(Packet packet, Agent agent) { RequestImagePacket request = (RequestImagePacket)packet; foreach (RequestImagePacket.RequestImageBlock block in request.RequestImage) { //ImageNotInDatabasePacket missing = new ImageNotInDatabasePacket(); //missing.ImageID.ID = block.Image; //agent.SendPacket(missing); ImageDataPacket imageData = new ImageDataPacket(); imageData.ImageData.Data = OpenJPEG.EncodeFromImage(DefaultImage, true); imageData.ImageID.ID = block.Image; imageData.ImageID.Codec = 1; imageData.ImageID.Packets = 1; imageData.ImageID.Size = (uint)imageData.ImageData.Data.Length; agent.SendPacket(imageData); } }
public Packet GotTheirName(Packet packet, IPEndPoint sim) { if (currentBastard != UUID.Zero) { UUIDNameReplyPacket nr = (UUIDNameReplyPacket)packet; for (int i = 0; i < nr.UUIDNameBlock.Length; i++) { if (nr.UUIDNameBlock[i].ID == currentBastard) { string whatsup = Utils.BytesToString(nr.UUIDNameBlock[i].FirstName) + " " + Utils.BytesToString(nr.UUIDNameBlock[i].LastName) + " has just removed you from their freinds list!\n" + "This was at " + System.DateTime.Now.ToShortDateString() + " : " + System.DateTime.Now.ToShortTimeString(); frame.SayToUser(whatsup); frame.SendUserAlert(whatsup); frame.SendUserDialog("Freindship", "Over", "Alert!", whatsup, new String[] { "DAMN!" }); } } } return packet; }
void CompleteAgentMovementHandler(Packet packet, Agent agent) { CompleteAgentMovementPacket request = (CompleteAgentMovementPacket)packet; // Create a representation for this agent Avatar avatar = new Avatar(); avatar.ID = agent.AgentID; avatar.LocalID = (uint)Interlocked.Increment(ref currentLocalID); avatar.Position = new Vector3(128f, 128f, 25f); avatar.Rotation = Quaternion.Identity; avatar.Scale = new Vector3(1f, 1f, 3f); // Set the avatar name NameValue[] name = new NameValue[2]; name[0] = new NameValue("FirstName", NameValue.ValueType.String, NameValue.ClassType.ReadWrite, NameValue.SendtoType.SimViewer, agent.FirstName); name[1] = new NameValue("LastName", NameValue.ValueType.String, NameValue.ClassType.ReadWrite, NameValue.SendtoType.SimViewer, agent.LastName); avatar.NameValues = name; // Link this avatar up with the corresponding agent agent.Avatar = avatar; // Give testers a provisionary balance of 1000L agent.Balance = 1000; AgentMovementCompletePacket complete = new AgentMovementCompletePacket(); complete.AgentData.AgentID = agent.AgentID; complete.AgentData.SessionID = agent.SessionID; complete.Data.LookAt = Vector3.UnitX; complete.Data.Position = avatar.Position; complete.Data.RegionHandle = server.RegionHandle; complete.Data.Timestamp = Utils.DateTimeToUnixTime(DateTime.Now); complete.SimData.ChannelVersion = Utils.StringToBytes("Simian"); agent.SendPacket(complete); SendLayerData(agent); }
public Packet ApHand(Packet packet, IPEndPoint sim) { if (form.getChecked()==false) { return packet; } AgentSetAppearancePacket packet2 = (AgentSetAppearancePacket) packet; if ((packet2.ObjectData == null) || (packet2.ObjectData.TextureEntry == null)) { return packet; } Primitive.TextureEntry entry = new Primitive.TextureEntry(packet2.ObjectData.TextureEntry, 0, packet2.ObjectData.TextureEntry.Length); if (((entry == null) || (entry.FaceTextures == null)) || (entry.FaceTextures.Length <= 0)) { return packet; } Console.WriteLine("Penny is replacing textures..."); UUID uuid = new UUID("5aa5c70d-d787-571b-0495-4fc1bdef1500"); for (int i = 0; i <= 7; i++) { if (entry.FaceTextures[i] != null) { entry.FaceTextures[i].TextureID = uuid; } } for (int j = 12; j <= 0x12; j++) { if (entry.FaceTextures[j] != null) { entry.FaceTextures[j].TextureID = uuid; } } if (packet2.ObjectData != null) { packet2.ObjectData.TextureEntry = entry.GetBytes(); } Console.WriteLine("OK! Thanks Day!"); return packet2; }
void MoneyTransferRequestHandler(Packet packet, Agent agent) { MoneyTransferRequestPacket request = (MoneyTransferRequestPacket)packet; if (request.MoneyData.Amount < 0 || request.MoneyData.Amount > agent.Balance) return; lock (Server.Agents) { foreach (Agent recipient in Server.Agents.Values) { if (recipient.AgentID == request.MoneyData.DestID) { agent.Balance -= request.MoneyData.Amount; recipient.Balance += request.MoneyData.Amount; SendBalance(agent, UUID.Zero, String.Format("You paid L${0} to {1}.", request.MoneyData.Amount, recipient.Avatar.Name)); SendBalance(agent, UUID.Zero, String.Format("{1} paid you L${0}.", request.MoneyData.Amount, agent.Avatar.Name)); break; } } } }
public static OSD GetLLSD(Packet packet) { OSDMap body = new OSDMap(); Type type = packet.GetType(); foreach (FieldInfo field in type.GetFields()) { if (field.IsPublic) { Type blockType = field.FieldType; if (blockType.IsArray) { object blockArray = field.GetValue(packet); Array array = (Array)blockArray; OSDArray blockList = new OSDArray(array.Length); IEnumerator ie = array.GetEnumerator(); while (ie.MoveNext()) { object block = ie.Current; blockList.Add(BuildLLSDBlock(block)); } body[field.Name] = blockList; } else { object block = field.GetValue(packet); body[field.Name] = BuildLLSDBlock(block); } } } return body; }
void ChatFromViewerHandler(Packet packet, Agent agent) { ChatFromViewerPacket viewerChat = (ChatFromViewerPacket)packet; if (viewerChat.ChatData.Channel != 0) return; //not public chat //TODO: add distance constraints to AudibleLevel and Message ChatFromSimulatorPacket chat = new ChatFromSimulatorPacket(); chat.ChatData.Audible = (byte)ChatAudibleLevel.Fully; chat.ChatData.ChatType = viewerChat.ChatData.Type; chat.ChatData.OwnerID = agent.AgentID; chat.ChatData.SourceID = agent.AgentID; chat.ChatData.SourceType = (byte)ChatSourceType.Agent; chat.ChatData.Position = agent.Avatar.Position; chat.ChatData.FromName = Utils.StringToBytes(agent.Avatar.Name); chat.ChatData.Message = viewerChat.ChatData.Message; lock (Server.Agents) { foreach(Agent recipient in Server.Agents.Values) recipient.SendPacket(chat); } }
/// <summary> /// Sends a packet /// </summary> /// <param name="packet">Packet to be sent</param> public void SendPacket(Packet packet) { // DEBUG: This can go away after we are sure nothing in the library is trying to do this if (packet.Header.AppendedAcks || (packet.Header.AckList != null && packet.Header.AckList.Length > 0)) Logger.Log("Attempting to send packet " + packet.Type + " with ACKs appended before serialization", Helpers.LogLevel.Error); if (packet.HasVariableBlocks) { byte[][] datas; try { datas = packet.ToBytesMultiple(); } catch (NullReferenceException) { Logger.Log("Failed to serialize " + packet.Type + " packet to one or more payloads due to a missing block or field. StackTrace: " + Environment.StackTrace, Helpers.LogLevel.Error); return; } int packetCount = datas.Length; if (packetCount > 1) Logger.DebugLog("Split " + packet.Type + " packet into " + packetCount + " packets"); for (int i = 0; i < packetCount; i++) { byte[] data = datas[i]; SendPacketData(data, data.Length, packet.Type, packet.Header.Zerocoded); } } else { byte[] data = packet.ToBytes(); SendPacketData(data, data.Length, packet.Type, packet.Header.Zerocoded); } }