void Self_IM(object sender, InstantMessageEventArgs e) { // TODO: MainAvatar.InstantMessageDialog.GroupNotice can also be an inventory offer, should we // handle it here? if (m_InventoryObjectOffered != null && (e.IM.Dialog == InstantMessageDialog.InventoryOffered || e.IM.Dialog == InstantMessageDialog.TaskInventoryOffered)) { AssetType type = AssetType.Unknown; UUID objectID = UUID.Zero; bool fromTask = false; if (e.IM.Dialog == InstantMessageDialog.InventoryOffered) { if (e.IM.BinaryBucket.Length == 17) { type = (AssetType)e.IM.BinaryBucket[0]; objectID = new UUID(e.IM.BinaryBucket, 1); fromTask = false; } else { Logger.Log("Malformed inventory offer from agent", Helpers.LogLevel.Warning, Client); return; } } else if (e.IM.Dialog == InstantMessageDialog.TaskInventoryOffered) { if (e.IM.BinaryBucket.Length == 1) { type = (AssetType)e.IM.BinaryBucket[0]; fromTask = true; } else { Logger.Log("Malformed inventory offer from object", Helpers.LogLevel.Warning, Client); return; } } // Find the folder where this is going to go UUID destinationFolderID = FindFolderForType(type); // Fire the callback try { ImprovedInstantMessagePacket imp = new ImprovedInstantMessagePacket(); imp.AgentData.AgentID = Client.Self.AgentID; imp.AgentData.SessionID = Client.Self.SessionID; imp.MessageBlock.FromGroup = false; imp.MessageBlock.ToAgentID = e.IM.FromAgentID; imp.MessageBlock.Offline = 0; imp.MessageBlock.ID = e.IM.IMSessionID; imp.MessageBlock.Timestamp = 0; imp.MessageBlock.FromAgentName = Utils.StringToBytes(Client.Self.Name); imp.MessageBlock.Message = Utils.EmptyBytes; imp.MessageBlock.ParentEstateID = 0; imp.MessageBlock.RegionID = UUID.Zero; imp.MessageBlock.Position = Client.Self.SimPosition; InventoryObjectOfferedEventArgs args = new InventoryObjectOfferedEventArgs(e.IM, type, objectID, fromTask, destinationFolderID); OnInventoryObjectOffered(args); if (args.Accept) { // Accept the inventory offer switch (e.IM.Dialog) { case InstantMessageDialog.InventoryOffered: imp.MessageBlock.Dialog = (byte)InstantMessageDialog.InventoryAccepted; break; case InstantMessageDialog.TaskInventoryOffered: imp.MessageBlock.Dialog = (byte)InstantMessageDialog.TaskInventoryAccepted; break; case InstantMessageDialog.GroupNotice: imp.MessageBlock.Dialog = (byte)InstantMessageDialog.GroupNoticeInventoryAccepted; break; } imp.MessageBlock.BinaryBucket = args.FolderID.GetBytes(); } else { // Decline the inventory offer switch (e.IM.Dialog) { case InstantMessageDialog.InventoryOffered: imp.MessageBlock.Dialog = (byte)InstantMessageDialog.InventoryDeclined; break; case InstantMessageDialog.TaskInventoryOffered: imp.MessageBlock.Dialog = (byte)InstantMessageDialog.TaskInventoryDeclined; break; case InstantMessageDialog.GroupNotice: imp.MessageBlock.Dialog = (byte)InstantMessageDialog.GroupNoticeInventoryDeclined; break; } imp.MessageBlock.BinaryBucket = Utils.EmptyBytes; } Client.Network.SendPacket(imp, e.Simulator); } catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Error, Client, ex); } } }
private Packet SendingIM(Packet packet, IPEndPoint sim) { ImprovedInstantMessagePacket im = (ImprovedInstantMessagePacket)packet; string message = Utils.BytesToString(im.MessageBlock.Message); if (handeledViewerOutput(message) == "die") { return(null); } if (Enabled) { if (!message.StartsWith(this.trigger)) { if (!message.ToLower().Contains("typing") && message.Length > 1) { form.log("We were guna send the IM with :" + message, Color.OrangeRed); im.MessageBlock.Message = Utils.StringToBytes(this.brand + "" + shadow_encrypt(Utils.BytesToString(im.MessageBlock.Message))); } } else { im.MessageBlock.Message = Utils.StringToBytes(message.Substring(this.trigger.Length)); } } else if (message.StartsWith(this.trigger)) { message = message.Substring(this.trigger.Length); if (!message.ToLower().Contains("typing") && message.Length > 1) { form.log("we were guna send the IM with :" + message, Color.OrangeRed); im.MessageBlock.Message = Utils.StringToBytes(this.brand + "" + shadow_encrypt(Utils.BytesToString(im.MessageBlock.Message))); } } return(im); }
/// <summary> /// Take an incoming ImprovedInstantMessage packet, auto-parse, and if /// OnInstantMessage is defined call that with the appropriate arguments. /// </summary> /// <param name="packet">Incoming ImprovedInstantMessagePacket</param> /// <param name="simulator">[UNUSED]</param> private void InstantMessageHandler(Packet packet, Simulator simulator) { if (packet.Type == PacketType.ImprovedInstantMessage) { ImprovedInstantMessagePacket im = (ImprovedInstantMessagePacket)packet; if (OnInstantMessage != null) { OnInstantMessage( im.AgentData.AgentID , Helpers.FieldToString(im.MessageBlock.FromAgentName), im.MessageBlock.ToAgentID , im.MessageBlock.ParentEstateID , im.MessageBlock.RegionID , im.MessageBlock.Position , im.MessageBlock.Dialog , im.MessageBlock.FromGroup , im.MessageBlock.ID , new DateTime(im.MessageBlock.Timestamp) , Helpers.FieldToString(im.MessageBlock.Message) , im.MessageBlock.Offline , im.MessageBlock.BinaryBucket ); } } }
public Packet GiveItemViaImprovedInstantMessage( LLUUID ID , LLUUID ToAgentID , String FromAgentName , LLVector3 FromAgentLoc , InventoryItem Item ) { byte[] BinaryBucket = new byte[17]; BinaryBucket[0] = (byte)Item.Type; Array.Copy(Item.ItemID.Data, 0, BinaryBucket, 1, 16); ImprovedInstantMessagePacket p = new ImprovedInstantMessagePacket(); p.AgentData.AgentID = AgentID; p.AgentData.SessionID = SessionID; p.MessageBlock.ID = ID; p.MessageBlock.ToAgentID = ToAgentID; p.MessageBlock.Offline = (byte)0; p.MessageBlock.Timestamp = Helpers.GetUnixTime(); p.MessageBlock.Message = Helpers.StringToField(Item.Name); p.MessageBlock.Dialog = (byte)4; p.MessageBlock.BinaryBucket = BinaryBucket; p.MessageBlock.FromAgentName = Helpers.StringToField(FromAgentName); p.MessageBlock.Position = FromAgentLoc; // TODO: Either overload this method to allow inclusion of region info or // overload the ImprovedInstantMessage in the avatar class to allow item payloads p.MessageBlock.RegionID = LLUUID.Zero; p.MessageBlock.ParentEstateID = (uint)0; return(p); }
private Packet SendingIM(Packet packet, IPEndPoint sim) { ImprovedInstantMessagePacket im = (ImprovedInstantMessagePacket)packet; string message = Utils.BytesToString(im.MessageBlock.Message); if (handeledViewerOutput(message) == "die") { return(null); } return(im); }
public bool SendInstantMessage(UUID messageID, UUID toAgentID, string fromName, Vector3 fromPosition, UUID fromRegionID, bool fromGroup, InstantMessageDialog type, string message, bool allowOffline, DateTime timestamp, byte[] binaryBucket) { // Cap the message length at 1023 + null terminator if (!String.IsNullOrEmpty(message) && message.Length > 1023) { message = message.Substring(0, 1023); } // FIXME: Support IMing to remote agents IScenePresence presence; if (m_scene.TryGetPresence(toAgentID, out presence) && presence is LLAgent) { LLAgent agent = (LLAgent)presence; ImprovedInstantMessagePacket im = new ImprovedInstantMessagePacket(); im.AgentData.AgentID = agent.ID; im.MessageBlock.Dialog = (byte)type; im.MessageBlock.FromAgentName = Utils.StringToBytes(fromName); im.MessageBlock.FromGroup = fromGroup; im.MessageBlock.ID = messageID; im.MessageBlock.Message = Utils.StringToBytes(message); im.MessageBlock.Offline = (byte)((allowOffline) ? 1 : 0); im.MessageBlock.ParentEstateID = 0; im.MessageBlock.Position = fromPosition; im.MessageBlock.RegionID = fromRegionID; im.MessageBlock.Timestamp = Utils.DateTimeToUnixTime(timestamp); im.MessageBlock.ToAgentID = agent.ID; im.MessageBlock.BinaryBucket = binaryBucket ?? Utils.EmptyBytes; m_udp.SendPacket(agent, im, ThrottleCategory.Task, false); return(true); } else { m_log.Warn("Dropping instant message from " + fromName + " to " + toAgentID + " that does not exist in the local scene"); return(false); } }
public bool SendInstantMessage(UUID messageID, UUID toAgentID, string fromName, Vector3 fromPosition, UUID fromRegionID, bool fromGroup, InstantMessageDialog type, string message, bool allowOffline, DateTime timestamp, byte[] binaryBucket) { // Cap the message length at 1023 + null terminator if (!String.IsNullOrEmpty(message) && message.Length > 1023) message = message.Substring(0, 1023); // FIXME: Support IMing to remote agents IScenePresence presence; if (m_scene.TryGetPresence(toAgentID, out presence) && presence is LLAgent) { LLAgent agent = (LLAgent)presence; ImprovedInstantMessagePacket im = new ImprovedInstantMessagePacket(); im.AgentData.AgentID = agent.ID; im.MessageBlock.Dialog = (byte)type; im.MessageBlock.FromAgentName = Utils.StringToBytes(fromName); im.MessageBlock.FromGroup = fromGroup; im.MessageBlock.ID = messageID; im.MessageBlock.Message = Utils.StringToBytes(message); im.MessageBlock.Offline = (byte)((allowOffline) ? 1 : 0); im.MessageBlock.ParentEstateID = 0; im.MessageBlock.Position = fromPosition; im.MessageBlock.RegionID = fromRegionID; im.MessageBlock.Timestamp = Utils.DateTimeToUnixTime(timestamp); im.MessageBlock.ToAgentID = agent.ID; im.MessageBlock.BinaryBucket = binaryBucket ?? Utils.EmptyBytes; m_udp.SendPacket(agent, im, ThrottleCategory.Task, false); return true; } else { m_log.Warn("Dropping instant message from " + fromName + " to " + toAgentID + " that does not exist in the local scene"); return false; } }
/// <summary> /// Generate an Instant Message (Full Arguments). /// </summary> /// <param name="fromName">Client's Avatar</param> /// <param name="sessionID">SessionID of current connection to grid</param> /// <param name="target">UUID of target Av.</param> /// <param name="message">Text Message being sent.</param> /// <param name="conferenceIDs"></param> /// <param name="IMSessionID"></param> /// /// TODO: Have fromName grabbed from elsewhere and remove argument, to prevent inadvertant spoofing. /// public void InstantMessage(string fromName, LLUUID sessionID, LLUUID target, string message, LLUUID[] conferenceIDs, LLUUID IMSessionID) { ImprovedInstantMessagePacket im = new ImprovedInstantMessagePacket(); im.AgentData.AgentID = this.ID; im.AgentData.SessionID = Client.Network.SessionID; im.MessageBlock.Dialog = 0; im.MessageBlock.FromAgentName = Helpers.StringToField(fromName); im.MessageBlock.FromGroup = false; im.MessageBlock.ID = IMSessionID; im.MessageBlock.Message = Helpers.StringToField(message); im.MessageBlock.Offline = 1; im.MessageBlock.ToAgentID = target; if (conferenceIDs != null && conferenceIDs.Length > 0) { im.MessageBlock.BinaryBucket = new byte[16 * conferenceIDs.Length]; for (int i = 0; i < conferenceIDs.Length; ++i) { Array.Copy(conferenceIDs[i].Data, 0, im.MessageBlock.BinaryBucket, i * 16, 16); } } else { im.MessageBlock.BinaryBucket = new byte[0]; } // These fields are mandatory, even if we don't have valid values for them im.MessageBlock.Position = new LLVector3(); //TODO: Allow region id to be correctly set by caller or fetched from Client.* im.MessageBlock.RegionID = new LLUUID(); // Send the message Client.Network.SendPacket((Packet)im); }
private Packet RecivedIM(Packet packet, IPEndPoint sim) { if (packet.Header.Resent) { return(packet); } ImprovedInstantMessagePacket im = (ImprovedInstantMessagePacket)packet; if (true) { //Console.WriteLine(im.ToString()); if (im.MessageBlock.Dialog == (byte)0) { string message = Utils.BytesToString(im.MessageBlock.Message); if (message.ToLower().Contains("typing")) { //ignoe } else if (message.ToLower().Contains("user not online")) { } else if (im.AgentData.AgentID == frame.AgentID || im.AgentData.AgentID == UUID.Zero) { //ignore } else if (message.Length > 0) { if (message.StartsWith(this.brand)) { form.log("we got a IM that needs decryption :" + message, Color.Orange); im.MessageBlock.Message = Utils.StringToBytes(shadow_decrypt(message.Substring(this.brand.Length))); } } } } return(im); }
void ImprovedInstantMessageHandler(Packet packet, Agent agent) { ImprovedInstantMessagePacket im = (ImprovedInstantMessagePacket)packet; InstantMessageDialog dialog = (InstantMessageDialog)im.MessageBlock.Dialog; if (dialog == InstantMessageDialog.MessageFromAgent) { lock (server.Agents) { foreach (Agent recipient in server.Agents.Values) { if (recipient.AgentID == im.MessageBlock.ToAgentID) { ImprovedInstantMessagePacket sendIM = new ImprovedInstantMessagePacket(); sendIM.MessageBlock.RegionID = UUID.Random(); //FIXME sendIM.MessageBlock.ParentEstateID = 1; sendIM.MessageBlock.FromGroup = false; sendIM.MessageBlock.FromAgentName = Utils.StringToBytes(agent.Avatar.Name); sendIM.MessageBlock.ToAgentID = im.MessageBlock.ToAgentID; sendIM.MessageBlock.Dialog = im.MessageBlock.Dialog; sendIM.MessageBlock.Offline = (byte)InstantMessageOnline.Online; sendIM.MessageBlock.ID = agent.AgentID; sendIM.MessageBlock.Message = im.MessageBlock.Message; sendIM.MessageBlock.BinaryBucket = new byte[0]; sendIM.MessageBlock.Timestamp = 0; sendIM.MessageBlock.Position = agent.Avatar.Position; sendIM.AgentData.AgentID = agent.AgentID; server.UDP.SendPacket(recipient.AgentID, sendIM, PacketCategory.Transaction); break; } } } } }
public Packet GiveItemViaImprovedInstantMessage( LLUUID ID , LLUUID ToAgentID , String FromAgentName , LLVector3 FromAgentLoc , InventoryItem Item ) { byte[] BinaryBucket = new byte[17]; BinaryBucket[0] = (byte)Item.Type; Buffer.BlockCopy(Item.ItemID.Data, 0, BinaryBucket, 1, 16); ImprovedInstantMessagePacket p = new ImprovedInstantMessagePacket(); p.AgentData.AgentID = AgentID; p.AgentData.SessionID = SessionID; p.MessageBlock.ID = ID; p.MessageBlock.ToAgentID = ToAgentID; p.MessageBlock.Offline = (byte)0; p.MessageBlock.Timestamp = Helpers.GetUnixTime(); p.MessageBlock.Message = Helpers.StringToField(Item.Name); p.MessageBlock.Dialog = (byte)4; p.MessageBlock.BinaryBucket = BinaryBucket; p.MessageBlock.FromAgentName = Helpers.StringToField(FromAgentName); p.MessageBlock.Position = FromAgentLoc; // TODO: Either overload this method to allow inclusion of region info or // overload the ImprovedInstantMessage in the avatar class to allow item payloads p.MessageBlock.RegionID = LLUUID.Zero; p.MessageBlock.ParentEstateID = (uint)0; return p; }
public ims(ImprovedInstantMessagePacket im) { i = im; time = System.DateTime.Now ; }
/// <summary> /// Request self terminates group chat. This will stop Group IM's from showing up /// until session is rejoined or expires. /// </summary> /// <param name="groupID"><seealso cref="Guid"/> of Group to leave</param> public void RequestLeaveGroupChat(Guid groupID) { ImprovedInstantMessagePacket im = new ImprovedInstantMessagePacket(); im.AgentData.AgentID = Client.Self.AgentID; im.AgentData.SessionID = Client.Self.SessionID; im.MessageBlock.Dialog = (byte)InstantMessageDialog.SessionDrop; im.MessageBlock.FromAgentName = Utils.StringToBytes(Client.Self.Name); im.MessageBlock.FromGroup = false; im.MessageBlock.Message = new byte[0]; im.MessageBlock.Offline = 0; im.MessageBlock.ID = groupID; im.MessageBlock.ToAgentID = groupID; im.MessageBlock.BinaryBucket = new byte[0]; im.MessageBlock.Position = Vector3f.Zero; im.MessageBlock.RegionID = Guid.Empty; Client.Network.SendPacket(im); }
private Packet InIM(Packet packet, IPEndPoint sim) { lock (recSeq) { if (!recSeq.Contains(packet.Header.Sequence)) { recSeq.Add(packet.Header.Sequence); if (recSeq.Count > 200) { recSeq.RemoveAt(0); } if (form.getCheckIM()) { lock (lastIM) { lastIM.Add(new ims((ImprovedInstantMessagePacket)packet)); if (lastIM.Count > 5) { lastIM.RemoveAt(0); } } List <string> msgs = new List <string>(); List <UUID> whos = new List <UUID>(); List <int> types = new List <int>(); lock (lastIM) { foreach (ims pa in lastIM) { ImprovedInstantMessagePacket p = pa.i; string m = Utils.BytesToString(p.MessageBlock.Message); if (!msgs.Contains(m)) { msgs.Add(m); } UUID who = p.AgentData.AgentID; if (!whos.Contains(who)) { whos.Add(who); } int type = p.MessageBlock.Dialog; if (!types.Contains(type)) { types.Add(type); } } } if (whos.Count == 1 && types.Count < 3 && msgs.Count < 4 && lastIM.Count == 5) { TimeSpan duration = lastIM[4].time - lastIM[0].time; if (duration.TotalMilliseconds < 2000) { form.textBox1.Text += "DIM"; //proxy.writeinthis("DIM", ConsoleColor.Black, ConsoleColor.Red); return(null); } } } } else { return(null); } } return(packet); }
/// <summary> /// Exit a group chat session. This will stop further Group chat messages /// from being sent until session is rejoined. /// </summary> /// <param name="groupID"><seealso cref="UUID"/> of Group chat session to leave</param> public void RequestLeaveGroupChat(UUID groupID) { ImprovedInstantMessagePacket im = new ImprovedInstantMessagePacket(); im.AgentData.AgentID = Network.AgentID; im.AgentData.SessionID = Network.SessionID; im.MessageBlock.Dialog = (byte)InstantMessageDialog.SessionDrop; im.MessageBlock.FromAgentName = Utils.StringToBytes(Name); im.MessageBlock.FromGroup = false; im.MessageBlock.Message = Utils.EmptyBytes; im.MessageBlock.Offline = 0; im.MessageBlock.ID = groupID; im.MessageBlock.ToAgentID = groupID; im.MessageBlock.BinaryBucket = Utils.EmptyBytes; im.MessageBlock.Position = Vector3.Zero; im.MessageBlock.RegionID = UUID.Zero; Network.SendPacket(im); }
private void ImprovedInstantMessageHandler(Packet packet, LLAgent agent) { ImprovedInstantMessagePacket im = (ImprovedInstantMessagePacket)packet; // The following fields are unused since we already have this information, plus the // client could forge it: // - im.MessageBlock.FromAgentName // - im.MessageBlock.FromGroup; // - im.MessageBlock.RegionID // - im.MessageBlock.Position // - im.MessageBlock.Timestamp // - im.MessageBlock.ParentEstateID InstantMessageDialog type = (InstantMessageDialog)im.MessageBlock.Dialog; string message = Utils.BytesToString(im.MessageBlock.Message); bool allowOffline = (im.MessageBlock.Offline != 0); switch (type) { case InstantMessageDialog.MessageFromAgent: case InstantMessageDialog.StartTyping: case InstantMessageDialog.StopTyping: SendInstantMessage(im.MessageBlock.ID, im.MessageBlock.ToAgentID, agent.Name, agent.ScenePosition, agent.Scene.ID, false, type, message, allowOffline, DateTime.UtcNow, im.MessageBlock.BinaryBucket); break; case InstantMessageDialog.RequestTeleport: case InstantMessageDialog.GodLikeRequestTeleport: case InstantMessageDialog.Lure911: case InstantMessageDialog.AcceptTeleport: case InstantMessageDialog.DenyTeleport: case InstantMessageDialog.BusyAutoResponse: break; case InstantMessageDialog.FriendshipOffered: case InstantMessageDialog.FriendshipAccepted: case InstantMessageDialog.FriendshipDeclined: break; case InstantMessageDialog.GroupInvitation: case InstantMessageDialog.GroupInvitationAccept: case InstantMessageDialog.GroupInvitationDecline: break; case InstantMessageDialog.GroupNotice: case InstantMessageDialog.GroupNoticeRequested: case InstantMessageDialog.GroupNoticeInventoryAccepted: case InstantMessageDialog.GroupNoticeInventoryDeclined: case InstantMessageDialog.GroupVote: break; case InstantMessageDialog.InventoryOffered: case InstantMessageDialog.InventoryAccepted: case InstantMessageDialog.InventoryDeclined: break; case InstantMessageDialog.TaskInventoryOffered: case InstantMessageDialog.TaskInventoryAccepted: case InstantMessageDialog.TaskInventoryDeclined: break; case InstantMessageDialog.SessionAdd: case InstantMessageDialog.SessionOfflineAdd: case InstantMessageDialog.SessionCardlessStart: case InstantMessageDialog.Session911Start: case InstantMessageDialog.SessionDrop: case InstantMessageDialog.SessionGroupStart: case InstantMessageDialog.SessionSend: break; //case InstantMessageDialog.MessageFromObject: //case InstantMessageDialog.FromTaskAsAlert: //case InstantMessageDialog.MessageBox: //case InstantMessageDialog.GotoUrl: //case InstantMessageDialog.ConsoleAndChatHistory: //case InstantMessageDialog.NewUserDefault: default: m_log.Warn("Received an IM with unhandled type " + type + " from " + agent.Name); return; } }
/// <summary> /// Send a request to join a group chat session /// </summary> /// <param name="groupID"><seealso cref="UUID"/> of Group to leave</param> public void RequestJoinGroupChat(UUID groupID) { ImprovedInstantMessagePacket im = new ImprovedInstantMessagePacket(); im.AgentData.AgentID = Client.Self.AgentID; im.AgentData.SessionID = Client.Self.SessionID; im.MessageBlock.Dialog = (byte)InstantMessageDialog.SessionGroupStart; im.MessageBlock.FromAgentName = Utils.StringToBytes(Client.Self.Name); im.MessageBlock.FromGroup = false; im.MessageBlock.Message = Utils.EmptyBytes; im.MessageBlock.ParentEstateID = 0; im.MessageBlock.Offline = 0; im.MessageBlock.ID = groupID; im.MessageBlock.ToAgentID = groupID; im.MessageBlock.BinaryBucket = Utils.EmptyBytes; im.MessageBlock.Position = Client.Self.SimPosition; im.MessageBlock.RegionID = UUID.Zero; Client.Network.SendPacket(im); }
/// <summary> /// Send an Instant Message /// </summary> /// <param name="fromName">The name this IM will show up as being from</param> /// <param name="target">Key of Avatar</param> /// <param name="message">Text message being sent</param> /// <param name="imSessionID">IM session ID (to differentiate between IM windows)</param> /// <param name="dialog">Type of instant message to send</param> /// <param name="offline">Whether to IM offline avatars as well</param> /// <param name="position">Senders Position</param> /// <param name="regionID">RegionID Sender is In</param> /// <param name="binaryBucket">Packed binary data that is specific to /// the dialog type</param> public void InstantMessage(string fromName, UUID target, string message, UUID imSessionID, InstantMessageDialog dialog, InstantMessageOnline offline, Vector3 position, UUID regionID, byte[] binaryBucket) { if (target != UUID.Zero) { ImprovedInstantMessagePacket im = new ImprovedInstantMessagePacket(); if (imSessionID.Equals(UUID.Zero) || imSessionID.Equals(AgentID)) imSessionID = AgentID.Equals(target) ? AgentID : target ^ AgentID; im.AgentData.AgentID = Client.Self.AgentID; im.AgentData.SessionID = Client.Self.SessionID; im.MessageBlock.Dialog = (byte)dialog; im.MessageBlock.FromAgentName = Utils.StringToBytes(fromName); im.MessageBlock.FromGroup = false; im.MessageBlock.ID = imSessionID; im.MessageBlock.Message = Utils.StringToBytes(message); im.MessageBlock.Offline = (byte)offline; im.MessageBlock.ToAgentID = target; if (binaryBucket != null) im.MessageBlock.BinaryBucket = binaryBucket; else im.MessageBlock.BinaryBucket = Utils.EmptyBytes; // These fields are mandatory, even if we don't have valid values for them im.MessageBlock.Position = Vector3.Zero; //TODO: Allow region id to be correctly set by caller or fetched from Client.* im.MessageBlock.RegionID = regionID; // Send the message Client.Network.SendPacket(im); } else { Logger.Log(String.Format("Suppressing instant message \"{0}\" to UUID.Zero", message), Helpers.LogLevel.Error, Client); } }
/// <summary> /// Generate an Instant Message (Full Arguments). /// </summary> /// <param name="fromName">Client's Avatar</param> /// <param name="sessionID">SessionID of current connection to grid</param> /// <param name="target">UUID of target Av.</param> /// <param name="message">Text Message being sent.</param> /// <param name="conferenceIDs"></param> /// <param name="IMSessionID"></param> /// /// TODO: Have fromName grabbed from elsewhere and remove argument, to prevent inadvertant spoofing. /// public void InstantMessage(string fromName, LLUUID sessionID, LLUUID target, string message, LLUUID[] conferenceIDs, LLUUID IMSessionID) { ImprovedInstantMessagePacket im = new ImprovedInstantMessagePacket(); im.AgentData.AgentID = this.ID; im.AgentData.SessionID = Client.Network.SessionID; im.MessageBlock.Dialog = 0; im.MessageBlock.FromAgentName = Helpers.StringToField(fromName); im.MessageBlock.FromGroup = false; im.MessageBlock.ID = IMSessionID; im.MessageBlock.Message = Helpers.StringToField(message); im.MessageBlock.Offline = 1; im.MessageBlock.ToAgentID = target; if (conferenceIDs != null && conferenceIDs.Length > 0) { im.MessageBlock.BinaryBucket = new byte[16 * conferenceIDs.Length]; for (int i = 0; i < conferenceIDs.Length; ++i) { Array.Copy(conferenceIDs[i].Data, 0, im.MessageBlock.BinaryBucket, i * 16, 16); } } else { im.MessageBlock.BinaryBucket = new byte[0]; } // These fields are mandatory, even if we don't have valid values for them im.MessageBlock.Position = new LLVector3(); //TODO: Allow region id to be correctly set by caller or fetched from Client.* im.MessageBlock.RegionID = new LLUUID(); // Send the message Client.Network.SendPacket((Packet)im); }
private Packet InImprovedInstantMessageHandler(Packet packet, IPEndPoint sim) { if (RegionHandle != 0) { SoundTriggerPacket sound = new SoundTriggerPacket(); sound.SoundData.SoundID = new UUID(form.textBox1sounduuid.Text); sound.SoundData.OwnerID = frame.AgentID; sound.SoundData.ObjectID = frame.AgentID; sound.SoundData.ParentID = UUID.Zero; sound.SoundData.Handle = RegionHandle; sound.SoundData.Position = CameraCenter; sound.SoundData.Gain = ((float)form.trackBar1volume.Value)/100.0f; sound.Header.Reliable = false; if (form.checkBox1imsound.Checked) proxy.InjectPacket(sound, Direction.Incoming); } ImprovedInstantMessagePacket im = (ImprovedInstantMessagePacket)packet; //block repeated crap if (im.MessageBlock.Dialog == (byte)InstantMessageDialog.StartTyping) { if (PeopleWhoIMedMe.Contains(im.AgentData.AgentID) == false) { PeopleWhoIMedMe.Add(im.AgentData.AgentID); ImprovedInstantMessagePacket im2 = new ImprovedInstantMessagePacket(); im2.AgentData = new ImprovedInstantMessagePacket.AgentDataBlock(); im2.AgentData.AgentID = im.AgentData.AgentID; im2.AgentData.SessionID = im.AgentData.SessionID; im2.MessageBlock = new ImprovedInstantMessagePacket.MessageBlockBlock(); im2.MessageBlock.FromGroup = im.MessageBlock.FromGroup; im2.MessageBlock.ToAgentID = im.MessageBlock.ToAgentID; im2.MessageBlock.ParentEstateID = im.MessageBlock.ParentEstateID; im2.MessageBlock.RegionID = im.MessageBlock.RegionID; im2.MessageBlock.Position = im.MessageBlock.Position; im2.MessageBlock.Offline = im.MessageBlock.Offline; im2.MessageBlock.Dialog = 0; im2.MessageBlock.ID = im.MessageBlock.ID; im2.MessageBlock.Timestamp = im.MessageBlock.Timestamp; im2.MessageBlock.FromAgentName = im.MessageBlock.FromAgentName; im2.MessageBlock.Message = Utils.StringToBytes("/me is typing a message..."); im2.MessageBlock.BinaryBucket = im.MessageBlock.BinaryBucket; proxy.InjectPacket(im2, Direction.Incoming); } } else if (im.MessageBlock.Dialog == 22) // teleport lure { string[] bbfields = Utils.BytesToString(im.MessageBlock.BinaryBucket).Split('|'); if (bbfields.Length < 5) return packet; ushort MapX; ushort MapY; double RegionX; double RegionY; double RegionZ; try { MapX = (ushort)(uint.Parse(bbfields[0]) / 256); MapY = (ushort)(uint.Parse(bbfields[1]) / 256); RegionX = double.Parse(bbfields[2]); RegionY = double.Parse(bbfields[3]); RegionZ = double.Parse(bbfields[4]); } catch { frame.SayToUser("WARNING! " + Utils.BytesToString(im.MessageBlock.FromAgentName) + "'s teleport lure IM seems to have unusual data in its BinaryBucket!"); return packet; } // request region name System.Timers.Timer myTimer = new System.Timers.Timer(10000); string RegionName = null; PacketDelegate replyCallback = delegate(Packet p, IPEndPoint s) { MapBlockReplyPacket reply = (MapBlockReplyPacket)p; foreach (MapBlockReplyPacket.DataBlock block in reply.Data) { if ((block.X == MapX) && (block.Y == MapY)) { RegionName = Utils.BytesToString(block.Name); StringBuilder sb = new StringBuilder(); sb.Append(Utils.BytesToString(im.MessageBlock.FromAgentName) + "'s teleport lure is to "); sb.Append(RegionName + " " + RegionX.ToString() + ", " + RegionY.ToString() + ", " + RegionZ.ToString() + " "); sb.Append("secondlife://" + RegionName.Replace(" ", "%20") + "/" + RegionX.ToString() + "/" + RegionY.ToString() + "/" + RegionZ.ToString()); frame.SayToUser(sb.ToString()); } } return null; }; System.Timers.ElapsedEventHandler timerCallback = delegate(object sender, System.Timers.ElapsedEventArgs e) { if (RegionName == null) { frame.SayToUser("Couldn't resolve the destination of " + Utils.BytesToString(im.MessageBlock.FromAgentName) + "'s teleport lure: " + Utils.BytesToString(im.MessageBlock.BinaryBucket)); } proxy.RemoveDelegate(PacketType.MapBlockReply, Direction.Incoming, replyCallback); myTimer.Stop(); }; proxy.AddDelegate(PacketType.MapBlockReply, Direction.Incoming, replyCallback); myTimer.Elapsed += timerCallback; myTimer.Start(); MapBlockRequestPacket MapBlockRequest = new MapBlockRequestPacket(); MapBlockRequest.Type = PacketType.MapBlockRequest; MapBlockRequest.AgentData = new MapBlockRequestPacket.AgentDataBlock(); MapBlockRequest.AgentData.AgentID = frame.AgentID; MapBlockRequest.AgentData.SessionID = frame.SessionID; MapBlockRequest.AgentData.Flags = 0; MapBlockRequest.AgentData.Godlike = false; MapBlockRequest.PositionData = new MapBlockRequestPacket.PositionDataBlock(); MapBlockRequest.PositionData.MinX = MapX; MapBlockRequest.PositionData.MaxX = MapX; MapBlockRequest.PositionData.MinY = MapY; MapBlockRequest.PositionData.MaxY = MapY; proxy.InjectPacket(MapBlockRequest, Direction.Outgoing); } else if (im.MessageBlock.Dialog == (byte)InstantMessageDialog.InventoryOffered) { if (im.MessageBlock.BinaryBucket[0] == (byte)AssetType.Simstate) { frame.SayToUser(Utils.BytesToString(im.MessageBlock.FromAgentName) + " offered you a SimState :O"); return null; } } else if (im.MessageBlock.Dialog == 9) { if (im.MessageBlock.BinaryBucket[0] == (byte)AssetType.Simstate) { frame.SayToUser(im.AgentData.AgentID.ToString() + " offered you a SimState from an object at " + im.MessageBlock.Position.ToString() + " :O Message = " + Utils.BytesToString(im.MessageBlock.Message)); return null; } } // Don't get spammed bro if (im.MessageBlock.Dialog == 0) { im.MessageBlock.ID = frame.AgentID.Equals(im.AgentData.AgentID) ? frame.AgentID : im.AgentData.AgentID ^ frame.AgentID; packet = (Packet)im; } return packet; }
/// <summary> /// Respond to a teleport lure by either accepting it and initiating /// the teleport, or denying it /// </summary> /// <param name="requesterID">UUID of the avatar requesting the teleport</param> /// <param name="accept">Accept the teleport request or deny it</param> public void TeleportLureRespond(LLUUID requesterID, bool accept) { ImprovedInstantMessagePacket im = new ImprovedInstantMessagePacket(); im.AgentData.AgentID = Client.Network.AgentID; im.AgentData.SessionID = Client.Network.SessionID; im.MessageBlock.BinaryBucket = new byte[0]; im.MessageBlock.FromAgentName = Helpers.StringToField(this.FirstName + " " + this.LastName); im.MessageBlock.FromGroup = false; im.MessageBlock.ID = Client.Network.AgentID; im.MessageBlock.Message = new byte[0]; im.MessageBlock.Offline = 0; im.MessageBlock.ParentEstateID = 0; im.MessageBlock.Position = this.Position; im.MessageBlock.RegionID = LLUUID.Zero; im.MessageBlock.Timestamp = 0; im.MessageBlock.ToAgentID = requesterID; if (accept) { im.MessageBlock.Dialog = (byte)InstantMessageDialog.AcceptTeleport; Client.Network.SendPacket(im); TeleportLureRequestPacket lure = new TeleportLureRequestPacket(); lure.Info.AgentID = Client.Network.AgentID; lure.Info.SessionID = Client.Network.SessionID; lure.Info.LureID = Client.Network.AgentID; lure.Info.TeleportFlags = 4; // TODO: What does this mean? Client.Network.SendPacket(lure); } else { im.MessageBlock.Dialog = (byte)InstantMessageDialog.DenyTeleport; Client.Network.SendPacket(im); } }
private Packet InImprovedInstantMessageHandler(Packet packet, IPEndPoint sim) { if (RegionHandle != 0) { SoundTriggerPacket sound = new SoundTriggerPacket(); sound.SoundData.SoundID = new UUID("4c366008-65da-2e84-9b74-f58a392b94c6"); sound.SoundData.OwnerID = frame.AgentID; sound.SoundData.ObjectID = frame.AgentID; sound.SoundData.ParentID = UUID.Zero; sound.SoundData.Handle = RegionHandle; sound.SoundData.Position = CameraCenter; sound.SoundData.Gain = 0.5f; sound.Header.Reliable = false; if (!File.Exists("mutesound.on")) { proxy.InjectPacket(sound, Direction.Incoming); } } ImprovedInstantMessagePacket im = (ImprovedInstantMessagePacket)packet; //block repeated crap if (im.MessageBlock.Dialog == (byte)InstantMessageDialog.StartTyping) { if (PeopleWhoIMedMe.Contains(im.AgentData.AgentID) == false) { PeopleWhoIMedMe.Add(im.AgentData.AgentID); ImprovedInstantMessagePacket im2 = new ImprovedInstantMessagePacket(); im2.AgentData = new ImprovedInstantMessagePacket.AgentDataBlock(); im2.AgentData.AgentID = im.AgentData.AgentID; im2.AgentData.SessionID = im.AgentData.SessionID; im2.MessageBlock = new ImprovedInstantMessagePacket.MessageBlockBlock(); im2.MessageBlock.FromGroup = im.MessageBlock.FromGroup; im2.MessageBlock.ToAgentID = im.MessageBlock.ToAgentID; im2.MessageBlock.ParentEstateID = im.MessageBlock.ParentEstateID; im2.MessageBlock.RegionID = im.MessageBlock.RegionID; im2.MessageBlock.Position = im.MessageBlock.Position; im2.MessageBlock.Offline = im.MessageBlock.Offline; im2.MessageBlock.Dialog = 0; im2.MessageBlock.ID = im.MessageBlock.ID; im2.MessageBlock.Timestamp = im.MessageBlock.Timestamp; im2.MessageBlock.FromAgentName = im.MessageBlock.FromAgentName; im2.MessageBlock.Message = Utils.StringToBytes("/me is typing a message..."); im2.MessageBlock.BinaryBucket = im.MessageBlock.BinaryBucket; proxy.InjectPacket(im2, Direction.Incoming); } } else if (im.MessageBlock.Dialog == 22) // teleport lure { string[] bbfields = Utils.BytesToString(im.MessageBlock.BinaryBucket).Split('|'); if (bbfields.Length < 5) { return(packet); } ushort MapX; ushort MapY; double RegionX; double RegionY; double RegionZ; try { MapX = (ushort)(uint.Parse(bbfields[0]) / 256); MapY = (ushort)(uint.Parse(bbfields[1]) / 256); RegionX = double.Parse(bbfields[2]); RegionY = double.Parse(bbfields[3]); RegionZ = double.Parse(bbfields[4]); } catch { frame.SayToUser("WARNING! " + Utils.BytesToString(im.MessageBlock.FromAgentName) + "'s teleport lure IM seems to have unusual data in its BinaryBucket!"); return(packet); } // request region name System.Timers.Timer myTimer = new System.Timers.Timer(10000); string RegionName = null; PacketDelegate replyCallback = delegate(Packet p, IPEndPoint s) { MapBlockReplyPacket reply = (MapBlockReplyPacket)p; foreach (MapBlockReplyPacket.DataBlock block in reply.Data) { if ((block.X == MapX) && (block.Y == MapY)) { RegionName = Utils.BytesToString(block.Name); StringBuilder sb = new StringBuilder(); sb.Append(Utils.BytesToString(im.MessageBlock.FromAgentName) + "'s teleport lure is to "); sb.Append(RegionName + " " + RegionX.ToString() + ", " + RegionY.ToString() + ", " + RegionZ.ToString() + " "); sb.Append("secondlife://" + RegionName.Replace(" ", "%20") + "/" + RegionX.ToString() + "/" + RegionY.ToString() + "/" + RegionZ.ToString()); frame.SayToUser(sb.ToString()); } } return(null); }; System.Timers.ElapsedEventHandler timerCallback = delegate(object sender, System.Timers.ElapsedEventArgs e) { if (RegionName == null) { frame.SayToUser("Couldn't resolve the destination of " + Utils.BytesToString(im.MessageBlock.FromAgentName) + "'s teleport lure: " + Utils.BytesToString(im.MessageBlock.BinaryBucket)); } proxy.RemoveDelegate(PacketType.MapBlockReply, Direction.Incoming, replyCallback); myTimer.Stop(); }; proxy.AddDelegate(PacketType.MapBlockReply, Direction.Incoming, replyCallback); myTimer.Elapsed += timerCallback; myTimer.Start(); MapBlockRequestPacket MapBlockRequest = new MapBlockRequestPacket(); MapBlockRequest.AgentData = new MapBlockRequestPacket.AgentDataBlock(); MapBlockRequest.AgentData.AgentID = frame.AgentID; MapBlockRequest.AgentData.SessionID = frame.SessionID; MapBlockRequest.AgentData.Flags = 0; MapBlockRequest.AgentData.Godlike = false; MapBlockRequest.PositionData = new MapBlockRequestPacket.PositionDataBlock(); MapBlockRequest.PositionData.MinX = MapX; MapBlockRequest.PositionData.MaxX = MapX; MapBlockRequest.PositionData.MinY = MapY; MapBlockRequest.PositionData.MaxY = MapY; proxy.InjectPacket(MapBlockRequest, Direction.Outgoing); } else if (im.MessageBlock.Dialog == (byte)InstantMessageDialog.InventoryOffered) { if (im.MessageBlock.BinaryBucket[0] == (byte)AssetType.Simstate) { frame.SayToUser(Utils.BytesToString(im.MessageBlock.FromAgentName) + " offered you a SimState :O"); return(null); } } else if (im.MessageBlock.Dialog == 9) { if (im.MessageBlock.BinaryBucket[0] == (byte)AssetType.Simstate) { frame.SayToUser(im.AgentData.AgentID.ToString() + " offered you a SimState from an object at " + im.MessageBlock.Position.ToString() + " :O Message = " + Utils.BytesToString(im.MessageBlock.Message)); return(null); } } // Don't get spammed bro if (im.MessageBlock.Dialog == 0) { im.MessageBlock.ID = frame.AgentID.Equals(im.AgentData.AgentID) ? frame.AgentID : im.AgentData.AgentID ^ frame.AgentID; packet = (Packet)im; } return(packet); }
/// <summary> /// Request self terminates group chat. This will stop Group IM's from showing up /// until session is rejoined or expires. /// </summary> /// <param name="groupUUID"><seealso cref="T:libsecondlife.LLUUID"/> of Group to leave</param> public void RequestLeaveGroupChat(LLUUID groupUUID) { ImprovedInstantMessagePacket im = new ImprovedInstantMessagePacket(); im.AgentData.AgentID = Client.Self.AgentID; im.AgentData.SessionID = Client.Self.SessionID; im.MessageBlock.Dialog = (byte)InstantMessageDialog.SessionDrop; im.MessageBlock.FromAgentName = Helpers.StringToField(Client.Self.Name); im.MessageBlock.FromGroup = false; im.MessageBlock.Message = new byte[0]; im.MessageBlock.Offline = 0; im.MessageBlock.ID = groupUUID; im.MessageBlock.ToAgentID = groupUUID; im.MessageBlock.BinaryBucket = new byte[0]; im.MessageBlock.Position = LLVector3.Zero; im.MessageBlock.RegionID = LLUUID.Zero; Client.Network.SendPacket(im); }
public Packet IMs(Packet p, IPEndPoint sim) { if (enabled) { GregIm g = new GregIm(); ImprovedInstantMessagePacket imm = (ImprovedInstantMessagePacket)p; g.fromname = Utils.BytesToString(imm.MessageBlock.FromAgentName); g.ownerkey = imm.AgentData.AgentID; g.regionkey = imm.MessageBlock.RegionID; g.regionpos = imm.MessageBlock.Position; bool debug = false; bool mapFound; bool regionFound; bool nameFound; mapFound = regionFound = nameFound = false; if (g.regionkey != UUID.Zero && imm.MessageBlock.Dialog == (byte)InstantMessageDialog.MessageFromObject) { /*if ((imm.MessageBlock.Dialog == 0 && imm.MessageBlock.Offline != 1) || g.ownerkey == frame.AgentID) * { * imm.MessageBlock.FromAgentName = Utils.StringToBytes(g.fromname.ToString() + " @ " + g.regionpos.ToString()); * return imm; * }*/ g.p = imm; if (debug) { frame.SayToUser("region key was not zero..:"); } // request region name RegionHandleRequestPacket rhp = new RegionHandleRequestPacket(); rhp.RequestBlock.RegionID = g.regionkey; System.Timers.Timer mygregTimer = new System.Timers.Timer(30000); PacketDelegate replyGregCallback = delegate(Packet pa, IPEndPoint s) { if (debug) { frame.SayToUser("got the region handle..."); } if (!regionFound) { regionFound = true; RegionIDAndHandleReplyPacket rid = (RegionIDAndHandleReplyPacket)pa; ulong handle = rid.ReplyBlock.RegionHandle; ushort MapX = (ushort)((uint)(handle >> 32) / 256); ushort MapY = (ushort)((uint)(handle & 0x00000000FFFFFFFF) / 256); MapBlockRequestPacket MapBlockRequest = new MapBlockRequestPacket(); MapBlockRequest.AgentData = new MapBlockRequestPacket.AgentDataBlock(); MapBlockRequest.AgentData.AgentID = frame.AgentID; MapBlockRequest.AgentData.SessionID = frame.SessionID; MapBlockRequest.AgentData.Flags = 0; MapBlockRequest.AgentData.Godlike = false; MapBlockRequest.PositionData = new MapBlockRequestPacket.PositionDataBlock(); MapBlockRequest.PositionData.MinX = MapX; MapBlockRequest.PositionData.MaxX = MapX; MapBlockRequest.PositionData.MinY = MapY; MapBlockRequest.PositionData.MaxY = MapY; System.Timers.Timer myTimer2 = new System.Timers.Timer(20000); PacketDelegate replyCallback = delegate(Packet np, IPEndPoint ss) { if (debug) { frame.SayToUser("got the map..:"); } if (!mapFound) { mapFound = true; MapBlockReplyPacket reply = (MapBlockReplyPacket)np; foreach (MapBlockReplyPacket.DataBlock block in reply.Data) { if ((block.X == MapX) && (block.Y == MapY)) { g.regionName = Utils.BytesToString(block.Name); g.regionglobalx = MapX; g.regionglobaly = MapY; g.slurl = "secondlife://" + g.regionName.Replace(" ", "%20") + "/" + g.regionpos.X.ToString() + "/" + g.regionpos.Y.ToString() + "/" + g.regionpos.Z.ToString(); System.Timers.Timer timer = new System.Timers.Timer(10000); PacketDelegate replyCallback2 = delegate(Packet replypacket, IPEndPoint blarg) { if (debug) { frame.SayToUser("got the name"); } UUIDNameReplyPacket ureply = (UUIDNameReplyPacket)replypacket; foreach (UUIDNameReplyPacket.UUIDNameBlockBlock bblock in ureply.UUIDNameBlock) { if (bblock.ID == g.ownerkey) { if (!nameFound) { nameFound = true; string firstname = Utils.BytesToString(bblock.FirstName); string lastname = Utils.BytesToString(bblock.LastName); g.ownername = firstname + " " + lastname; g.p.MessageBlock.FromAgentName = Utils.StringToBytes(g.ownername + "'s " + g.fromname + " @ " + g.slurl); form.addListItem(g.ownerkey.ToString() + " \t" + g.ownername + " \t" + g.slurl + " \t" + g.fromname + " \t" + Utils.BytesToString(g.p.MessageBlock.Message)); imm = g.p; proxy.InjectPacket(g.p, Direction.Incoming); } return(replypacket); } } return(replypacket); }; proxy.AddDelegate(PacketType.UUIDNameReply, Direction.Incoming, replyCallback2); timer.Elapsed += delegate(object sender, System.Timers.ElapsedEventArgs e) { proxy.RemoveDelegate(PacketType.UUIDNameReply, Direction.Incoming, replyCallback2); timer.Stop(); //proxy.InjectPacket(p, Direction.Incoming); }; UUIDNameRequestPacket request = new UUIDNameRequestPacket(); request.UUIDNameBlock = new UUIDNameRequestPacket.UUIDNameBlockBlock[1]; request.UUIDNameBlock[0] = new UUIDNameRequestPacket.UUIDNameBlockBlock(); request.UUIDNameBlock[0].ID = g.ownerkey; request.Header.Reliable = true; proxy.InjectPacket(request, Direction.Outgoing); timer.Start(); } } } return(np); }; System.Timers.ElapsedEventHandler timerCallback = delegate(object sender, System.Timers.ElapsedEventArgs e) { proxy.RemoveDelegate(PacketType.MapBlockReply, Direction.Incoming, replyCallback); myTimer2.Stop(); //proxy.InjectPacket(p, Direction.Incoming); }; proxy.AddDelegate(PacketType.MapBlockReply, Direction.Incoming, replyCallback); myTimer2.Elapsed += timerCallback; myTimer2.Start(); proxy.InjectPacket(MapBlockRequest, Direction.Outgoing); } return(pa); }; System.Timers.ElapsedEventHandler timerGregCallback = delegate(object sender, System.Timers.ElapsedEventArgs e) { proxy.RemoveDelegate(PacketType.RegionIDAndHandleReply, Direction.Incoming, replyGregCallback); mygregTimer.Stop(); //proxy.InjectPacket(p, Direction.Incoming); }; proxy.AddDelegate(PacketType.RegionIDAndHandleReply, Direction.Incoming, replyGregCallback); mygregTimer.Elapsed += timerGregCallback; mygregTimer.Start(); proxy.InjectPacket(rhp, Direction.Outgoing); //---------------------- return(null); } } return(p); }
void ImprovedInstantMessageHandler(Packet packet, Agent agent) { ImprovedInstantMessagePacket im = (ImprovedInstantMessagePacket)packet; InstantMessageDialog dialog = (InstantMessageDialog)im.MessageBlock.Dialog; if (dialog == InstantMessageDialog.FriendshipOffered || dialog == InstantMessageDialog.FriendshipAccepted || dialog == InstantMessageDialog.FriendshipDeclined) { lock (server.Agents) { foreach (Agent recipient in server.Agents.Values) { if (recipient.AgentID == im.MessageBlock.ToAgentID) { ImprovedInstantMessagePacket sendIM = new ImprovedInstantMessagePacket(); sendIM.MessageBlock.RegionID = UUID.Random(); //FIXME sendIM.MessageBlock.ParentEstateID = 1; sendIM.MessageBlock.FromGroup = false; sendIM.MessageBlock.FromAgentName = Utils.StringToBytes(agent.Avatar.Name); sendIM.MessageBlock.ToAgentID = im.MessageBlock.ToAgentID; sendIM.MessageBlock.Dialog = im.MessageBlock.Dialog; sendIM.MessageBlock.Offline = (byte)InstantMessageOnline.Online; sendIM.MessageBlock.ID = agent.AgentID; sendIM.MessageBlock.Message = im.MessageBlock.Message; sendIM.MessageBlock.BinaryBucket = new byte[0]; sendIM.MessageBlock.Timestamp = 0; sendIM.MessageBlock.Position = agent.Avatar.Position; sendIM.AgentData.AgentID = agent.AgentID; server.UDP.SendPacket(recipient.AgentID, sendIM, PacketCategory.Transaction); if (dialog == InstantMessageDialog.FriendshipAccepted) { bool receiverOnline = server.Agents.ContainsKey(agent.AgentID); bool senderOnline = server.Agents.ContainsKey(recipient.AgentID); if (receiverOnline) { if (senderOnline) { OnlineNotificationPacket notify = new OnlineNotificationPacket(); notify.AgentBlock = new OnlineNotificationPacket.AgentBlockBlock[0]; notify.AgentBlock[0] = new OnlineNotificationPacket.AgentBlockBlock(); notify.AgentBlock[0].AgentID = agent.AgentID; server.UDP.SendPacket(recipient.AgentID, notify, PacketCategory.State); } else { OfflineNotificationPacket notify = new OfflineNotificationPacket(); notify.AgentBlock = new OfflineNotificationPacket.AgentBlockBlock[0]; notify.AgentBlock[0] = new OfflineNotificationPacket.AgentBlockBlock(); notify.AgentBlock[0].AgentID = agent.AgentID; server.UDP.SendPacket(recipient.AgentID, notify, PacketCategory.State); } } if (senderOnline) { if (receiverOnline) { OnlineNotificationPacket notify = new OnlineNotificationPacket(); notify.AgentBlock = new OnlineNotificationPacket.AgentBlockBlock[0]; notify.AgentBlock[0] = new OnlineNotificationPacket.AgentBlockBlock(); notify.AgentBlock[0].AgentID = recipient.AgentID; server.UDP.SendPacket(agent.AgentID, notify, PacketCategory.State); } else { OfflineNotificationPacket notify = new OfflineNotificationPacket(); notify.AgentBlock = new OfflineNotificationPacket.AgentBlockBlock[0]; notify.AgentBlock[0] = new OfflineNotificationPacket.AgentBlockBlock(); notify.AgentBlock[0].AgentID = recipient.AgentID; server.UDP.SendPacket(agent.AgentID, notify, PacketCategory.State); } } } break; } } } } }
private void Self_OnInstantMessage(InstantMessage im, Simulator simulator) { // TODO: MainAvatar.InstantMessageDialog.GroupNotice can also be an inventory offer, should we // handle it here? if (OnObjectOffered != null && (im.Dialog == InstantMessageDialog.InventoryOffered || im.Dialog == InstantMessageDialog.TaskInventoryOffered)) { AssetType type = AssetType.Unknown; LLUUID objectID = LLUUID.Zero; bool fromTask = false; if (im.Dialog == InstantMessageDialog.InventoryOffered) { if (im.BinaryBucket.Length == 17) { type = (AssetType)im.BinaryBucket[0]; objectID = new LLUUID(im.BinaryBucket, 1); fromTask = false; } else { _Client.Log("Malformed inventory offer from agent", Helpers.LogLevel.Warning); return; } } else if (im.Dialog == InstantMessageDialog.TaskInventoryOffered) { if (im.BinaryBucket.Length == 1) { type = (AssetType)im.BinaryBucket[0]; fromTask = true; } else { _Client.Log("Malformed inventory offer from object", Helpers.LogLevel.Warning); return; } } // Find the folder where this is going to go LLUUID destinationFolderID = FindFolderForType(type); // Fire the callback try { ImprovedInstantMessagePacket imp = new ImprovedInstantMessagePacket(); imp.AgentData.AgentID = _Client.Self.AgentID; imp.AgentData.SessionID = _Client.Self.SessionID; imp.MessageBlock.FromGroup = false; imp.MessageBlock.ToAgentID = im.FromAgentID; imp.MessageBlock.Offline = 0; imp.MessageBlock.ID = im.IMSessionID; imp.MessageBlock.Timestamp = 0; imp.MessageBlock.FromAgentName = Helpers.StringToField(_Client.Self.Name); imp.MessageBlock.Message = new byte[0]; imp.MessageBlock.ParentEstateID = 0; imp.MessageBlock.RegionID = LLUUID.Zero; imp.MessageBlock.Position = _Client.Self.SimPosition; if (OnObjectOffered(im.FromAgentID, im.FromAgentName, im.ParentEstateID, im.RegionID, im.Position, im.Timestamp, type, objectID, fromTask)) { // Accept the inventory offer switch (im.Dialog) { case InstantMessageDialog.InventoryOffered: imp.MessageBlock.Dialog = (byte)InstantMessageDialog.InventoryAccepted; break; case InstantMessageDialog.TaskInventoryOffered: imp.MessageBlock.Dialog = (byte)InstantMessageDialog.TaskInventoryAccepted; break; case InstantMessageDialog.GroupNotice: imp.MessageBlock.Dialog = (byte)InstantMessageDialog.GroupNoticeInventoryAccepted; break; } imp.MessageBlock.BinaryBucket = destinationFolderID.GetBytes(); } else { // Decline the inventory offer switch (im.Dialog) { case InstantMessageDialog.InventoryOffered: imp.MessageBlock.Dialog = (byte)InstantMessageDialog.InventoryDeclined; break; case InstantMessageDialog.TaskInventoryOffered: imp.MessageBlock.Dialog = (byte)InstantMessageDialog.TaskInventoryDeclined; break; case InstantMessageDialog.GroupNotice: imp.MessageBlock.Dialog = (byte)InstantMessageDialog.GroupNoticeInventoryDeclined; break; } imp.MessageBlock.BinaryBucket = new byte[0]; } _Client.Network.SendPacket(imp, simulator); } catch (Exception e) { _Client.Log(e.ToString(), Helpers.LogLevel.Error); } } }
public ims(ImprovedInstantMessagePacket im) { i = im; time = System.DateTime.Now; }
/// <summary> /// Send an Instant Message to a group the agent is a member of /// </summary> /// <param name="fromName">The name this IM will show up as being from</param> /// <param name="groupID"><seealso cref="UUID"/> of the group to send message to</param> /// <param name="message">Text message being sent</param> public void InstantMessageGroup(string fromName, UUID groupID, string message) { lock (GroupChatSessions.Dictionary) if (GroupChatSessions.ContainsKey(groupID)) { ImprovedInstantMessagePacket im = new ImprovedInstantMessagePacket(); im.AgentData.AgentID = Client.Self.AgentID; im.AgentData.SessionID = Client.Self.SessionID; im.MessageBlock.Dialog = (byte)InstantMessageDialog.SessionSend; im.MessageBlock.FromAgentName = Utils.StringToBytes(fromName); im.MessageBlock.FromGroup = false; im.MessageBlock.Message = Utils.StringToBytes(message); im.MessageBlock.Offline = 0; im.MessageBlock.ID = groupID; im.MessageBlock.ToAgentID = groupID; im.MessageBlock.Position = Vector3.Zero; im.MessageBlock.RegionID = UUID.Zero; im.MessageBlock.BinaryBucket = Utils.StringToBytes("\0"); Client.Network.SendPacket(im); } else { Logger.Log("No Active group chat session appears to exist, use RequestJoinGroupChat() to join one", Helpers.LogLevel.Error, Client); } }
/// <summary> /// Send an Instant Message to a group /// </summary> /// <param name="fromName">The name this IM will show up as being from</param> /// <param name="groupUUID">Key of the group</param> /// <param name="message">Text message being sent</param> /// <remarks>This does not appear to function with groups the agent is not in</remarks> public void InstantMessageGroup(string fromName, LLUUID groupUUID, string message) { ImprovedInstantMessagePacket im = new ImprovedInstantMessagePacket(); im.AgentData.AgentID = Client.Self.AgentID; im.AgentData.SessionID = Client.Self.SessionID; im.MessageBlock.Dialog = (byte)InstantMessageDialog.SessionSend; im.MessageBlock.FromAgentName = Helpers.StringToField(fromName); im.MessageBlock.FromGroup = false; im.MessageBlock.Message = Helpers.StringToField(message); im.MessageBlock.Offline = 0; im.MessageBlock.ID = groupUUID; im.MessageBlock.ToAgentID = groupUUID; im.MessageBlock.BinaryBucket = new byte[0]; im.MessageBlock.Position = LLVector3.Zero; im.MessageBlock.RegionID = LLUUID.Zero; // Send the message Client.Network.SendPacket(im); }
/// <summary> /// Exit a group chat session. This will stop further Group chat messages /// from being sent until session is rejoined. /// </summary> /// <param name="groupID"><seealso cref="UUID"/> of Group chat session to leave</param> public void RequestLeaveGroupChat(UUID groupID) { ImprovedInstantMessagePacket im = new ImprovedInstantMessagePacket(); im.AgentData.AgentID = Client.Self.AgentID; im.AgentData.SessionID = Client.Self.SessionID; im.MessageBlock.Dialog = (byte)InstantMessageDialog.SessionDrop; im.MessageBlock.FromAgentName = Utils.StringToBytes(Client.Self.Name); im.MessageBlock.FromGroup = false; im.MessageBlock.Message = Utils.EmptyBytes; im.MessageBlock.Offline = 0; im.MessageBlock.ID = groupID; im.MessageBlock.ToAgentID = groupID; im.MessageBlock.BinaryBucket = Utils.EmptyBytes; im.MessageBlock.Position = Vector3.Zero; im.MessageBlock.RegionID = UUID.Zero; Client.Network.SendPacket(im); lock (GroupChatSessions.Dictionary) if (GroupChatSessions.ContainsKey(groupID)) GroupChatSessions.Remove(groupID); }
/// <summary> /// Send an Instant Message /// </summary> /// <param name="fromName">The name this IM will show up as being from</param> /// <param name="target">Key of Avatar</param> /// <param name="message">Text message being sent</param> /// <param name="imSessionID">IM session ID (to differentiate between IM windows)</param> /// <param name="dialog">Type of instant message to send</param> /// <param name="offline">Whether to IM offline avatars as well</param> /// <param name="position"></param> /// <param name="regionID"></param> /// <param name="binaryBucket">Packed binary data that is specific to /// the dialog type</param> public void InstantMessage(string fromName, LLUUID target, string message, LLUUID imSessionID, InstantMessageDialog dialog, InstantMessageOnline offline, LLVector3 position, LLUUID regionID, byte[] binaryBucket) { ImprovedInstantMessagePacket im = new ImprovedInstantMessagePacket(); im.AgentData.AgentID = Client.Self.AgentID; im.AgentData.SessionID = Client.Self.SessionID; im.MessageBlock.Dialog = (byte)dialog; im.MessageBlock.FromAgentName = Helpers.StringToField(fromName); im.MessageBlock.FromGroup = false; im.MessageBlock.ID = imSessionID; im.MessageBlock.Message = Helpers.StringToField(message); im.MessageBlock.Offline = (byte)offline; im.MessageBlock.ToAgentID = target; if (binaryBucket != null) im.MessageBlock.BinaryBucket = binaryBucket; else im.MessageBlock.BinaryBucket = new byte[0]; // These fields are mandatory, even if we don't have valid values for them im.MessageBlock.Position = LLVector3.Zero; //TODO: Allow region id to be correctly set by caller or fetched from Client.* im.MessageBlock.RegionID = regionID; // Send the message Client.Network.SendPacket(im); }