Esempio n. 1
0
        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);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Group Chat Request
        /// </summary>
        /// <param name="capsKey">Caps Key</param>
        /// <param name="llsd">LLSD Map containing invitation</param>
        /// <param name="simulator">Originating Simulator</param>
        private void ChatterBoxInvitationHandler(string capsKey, LLSD llsd, Simulator simulator)
        {       
                if (OnInstantMessage != null)
                {
                    LLSDMap map = (LLSDMap)llsd;
                    LLSDMap im = (LLSDMap)map["instantmessage"];
                    LLSDMap agent = (LLSDMap)im["agent_params"];
                    LLSDMap msg = (LLSDMap)im["message_params"];
                    LLSDMap msgdata = (LLSDMap)msg["data"];

                    InstantMessage message = new InstantMessage();
                    
                    message.FromAgentID = map["from_id"].AsUUID();
                    message.FromAgentName = map["from_name"].AsString();
                    message.ToAgentID = msg["to_id"].AsString();
                    message.ParentEstateID = (uint)msg["parent_estate_id"].AsInteger();
                    message.RegionID = msg["region_id"].AsUUID();
                    message.Position.FromLLSD(msg["position"]);
                    message.Dialog = (InstantMessageDialog)msgdata["type"].AsInteger();
                    message.GroupIM = true;
                    message.IMSessionID = map["session_id"].AsUUID();
                    message.Timestamp = new DateTime(msgdata["timestamp"].AsInteger());
                    message.Message = msg["message"].AsString();
                    message.Offline = (InstantMessageOnline)msg["offline"].AsInteger();
                    message.BinaryBucket = msg["binary_bucket"].AsBinary();

                    try { OnInstantMessage(message, simulator); }
                    catch (Exception e) { Client.Log(e.ToString(), Helpers.LogLevel.Error); }
                }             
        }
Esempio n. 3
0
        private void Self_OnInstantMessage(InstantMessage im, Simulator simulator)
        {

            bool groupIM = im.GroupIM && GroupMembers != null && GroupMembers.ContainsKey(im.FromAgentID) ? true : false;

            if (im.FromAgentID == MasterKey || (GroupCommands && groupIM))
            {
                // Received an IM from someone that is authenticated
                Console.WriteLine("<{0} ({1})> {2}: {3} (@{4}:{5})", im.GroupIM ? "GroupIM" : "IM", im.Dialog, im.FromAgentName, im.Message, im.RegionID, im.Position);

                if (im.Dialog == InstantMessageDialog.RequestTeleport)
                {
                    Console.WriteLine("Accepting teleport lure.");
                    Self.TeleportLureRespond(im.FromAgentID, true);
                }
                else if (
                    im.Dialog == InstantMessageDialog.MessageFromAgent ||
                    im.Dialog == InstantMessageDialog.MessageFromObject)
                {
                    DoCommand(im.Message, im.FromAgentID);
                }
            }

            else
            {
                // Received an IM from someone that is not the bot's master, ignore
                Console.WriteLine("<{0} ({1})> {2} (not master): {3} (@{4}:{5})", im.GroupIM ? "GroupIM" : "IM", im.Dialog, im.FromAgentName, im.Message,
                    im.RegionID, im.Position);
                return;
            }

        }
Esempio n. 4
0
        void onIMReceive(InstantMessage im, Simulator simulator)
        {
            #if DEBUG
            Console.WriteLine("<{0} ({1})> {2}: {3} (@{4}:{5})",
                im.GroupIM ? "GroupIM" : "IM", im.Dialog, im.FromAgentName, im.Message,
                im.RegionID, im.Position);
            #endif
			string[] sender = im.FromAgentName.Split(' ');
            XmlRpcAgencyConnector.MethodName = "XmlRpcAgencyConnector.onIMReceive";
            XmlRpcAgencyConnector.Params.Clear();
            XmlRpcAgencyConnector.Params.Add(agentName);
            XmlRpcAgencyConnector.Params.Add(im.Message);
            XmlRpcAgencyConnector.Params.Add(sender[0]);
            XmlRpcAgencyConnector.Params.Add(sender[1]);

            try
            {
                #if DEBUG
                Console.WriteLine("Request: " + XmlRpcAgencyConnector);
                #endif
                XmlRpcResponse response = XmlRpcAgencyConnector.Send(XmlRpcAgencyConnectorUrl);
                #if DEBUG
                Console.WriteLine("Response: " + response);
                #endif

                if (response.IsFault)
                {
                    #if DEBUG
                    Console.WriteLine("Fault {0}: {1}", response.FaultCode, response.FaultString);
                    #endif
                }
                else
                {
                    #if DEBUG
                    Console.WriteLine("Returned: " + response.Value);
                    #endif
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception " + e);
            }
        }
Esempio n. 5
0
        private void Self_OnInstantMessage(InstantMessage im, Simulator simulator)
        {
            if (MasterKey != LLUUID.Zero)
            {
                if (im.FromAgentID != MasterKey)
                {
                    // Received an IM from someone that is not the bot's master, ignore
                    Console.WriteLine("<IM ({0})> {1} (not master): {2} (@{3}:{4})", im.Dialog, im.FromAgentName, im.Message,
                        im.RegionID, im.Position);
                    return;
                }
            }
            else if (GroupMembers != null && !GroupMembers.ContainsKey(im.FromAgentID))
            {
                // Received an IM from someone outside the bot's group, ignore
                Console.WriteLine("<IM ({0})> {1} (not in group): {2} (@{3}:{4})", im.Dialog, im.FromAgentName,
                    im.Message, im.RegionID, im.Position);
                return;
            }

            // Received an IM from someone that is authenticated
            Console.WriteLine("<IM ({0})> {1}: {2} (@{3}:{4})", im.Dialog, im.FromAgentName, im.Message, im.RegionID, im.Position);

            if (im.Dialog == InstantMessageDialog.RequestTeleport)
            {
                Console.WriteLine("Accepting teleport lure.");
                Self.TeleportLureRespond(im.FromAgentID, true);
            }
            else if (
                im.Dialog == InstantMessageDialog.MessageFromAgent ||
                im.Dialog == InstantMessageDialog.MessageFromObject)
            {
                DoCommand(im.Message, im.FromAgentID);
            }
        }
Esempio n. 6
0
 public void Self_OnInstantMessage(InstantMessage im, Simulator simulator)
 {
     LLUUID fromAgentID = im.FromAgentID;
     string fromAgentName = im.FromAgentName;
     //LLUUID toAgentID = im.ToAgentID;
     LLUUID regionID = im.RegionID;
     LLVector3 position = im.Position;
     InstantMessageDialog dialog = im.Dialog;
     bool groupIM = im.GroupIM;
     LLUUID imSessionID = im.IMSessionID;
     DateTime timestamp = im.Timestamp;
     string message = im.Message;
     InstantMessageOnline offline = im.Offline;
     byte[] binaryBucket = im.BinaryBucket;
     uint parentEstateID = im.ParentEstateID;
     Hashtable item = new Hashtable();
     item.Add("MessageType", "InstantMessage");
     item.Add("FromAgentID", fromAgentID);
     item.Add("FromAgentName", fromAgentName);
     item.Add("ParentEstateID", parentEstateID.ToString());
     item.Add("RegionID", regionID);
     item.Add("Position", position);
     item.Add("Dialog", dialog);
     item.Add("GroupIM", groupIM);
     item.Add("IMSessionID", imSessionID);
     item.Add("Timestamp", timestamp);
     item.Add("Message", message);
     item.Add("Offline", offline);
     item.Add("BinaryBucket", binaryBucket);
     enqueue(item);
 }
Esempio n. 7
0
        private void Self_OnInstantMessage(InstantMessage im, Simulator simulator)
        {
            InstantMessageEventArgs ea = new InstantMessageEventArgs(im, simulator);

            if (netcomSync != null)
                netcomSync.BeginInvoke(new OnInstantMessageRaise(OnInstantMessageReceived), new object[] { ea });
            else
                OnInstantMessageReceived(ea);
        }
Esempio n. 8
0
 public bool Inventory_OnObjectOffered(InstantMessage offerDetails, AssetType type, LLUUID objectID, bool fromTask)
 {
     if (!active) return false;
     Hashtable hashtable = new Hashtable();
     hashtable.Add("MessageType", "ObjectOffered");
     hashtable.Add("FromAgentID", offerDetails.FromAgentID);
     hashtable.Add("FromAgentName", offerDetails.FromAgentName);
     hashtable.Add("RegionID", offerDetails.RegionID);
     hashtable.Add("Position", offerDetails.Position);
     hashtable.Add("Timestamp", offerDetails.Timestamp);
     hashtable.Add("Type", type);
     hashtable.Add("ObjectID", objectID);
     hashtable.Add("FromTask", fromTask);
     enqueue(hashtable);
     return true; // Sigh...
 }
Esempio n. 9
0
        private bool Inventory_OnInventoryObjectReceived(InstantMessage offer, AssetType type,
            LLUUID objectID, bool fromTask)
        {
            if (MasterKey != LLUUID.Zero)
            {
                if (offer.FromAgentID != MasterKey)
                    return false;
            }
            else if (GroupMembers != null && !GroupMembers.ContainsKey(offer.FromAgentID))
            {
                return false;
            }

            return true;
        }
Esempio n. 10
0
        /// <summary>
        /// Handles relevant messages from the server encapsulated in instant messages.
        /// </summary>
        /// <param name="im">InstantMessage object containing encapsalated instant message</param>
        /// <param name="simulator">Originating Simulator</param>
        private void MainAvatar_InstantMessage(InstantMessage im, Simulator simulator)
        {
            if (im.Dialog == InstantMessageDialog.FriendshipOffered)
            {
                if (OnFriendshipOffered != null)
                {
                    lock (FriendRequests)
                    {
                        if (FriendRequests.ContainsKey(im.FromAgentID))
                        	FriendRequests[im.FromAgentID] = im.IMSessionID;
                        else
                        	FriendRequests.Add(im.FromAgentID, im.IMSessionID);
                    }
                    try { OnFriendshipOffered(im.FromAgentID, im.FromAgentName, im.IMSessionID); }
                    catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); }
                }
            }
            else if (im.Dialog == InstantMessageDialog.FriendshipAccepted)
            {
                FriendInfo friend = new FriendInfo(im.FromAgentID, FriendRights.CanSeeOnline,
                    FriendRights.CanSeeOnline);
                friend.Name = im.FromAgentName;
                lock (FriendList) FriendList[friend.UUID] = friend;

                if (OnFriendshipResponse != null)
                {
                    try { OnFriendshipResponse(im.FromAgentID, im.FromAgentName, true); }
                    catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); }
                }
            }
            else if (im.Dialog == InstantMessageDialog.FriendshipDeclined)
            {
                if (OnFriendshipResponse != null)
                {
                    try { OnFriendshipResponse(im.FromAgentID, im.FromAgentName, false); }
                    catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); }
                }
            }
        }
Esempio n. 11
0
 void Self_OnInstantMessage(InstantMessage im, Simulator simulator)
 {
     switch (im.Dialog)
     {
         case InstantMessageDialog.MessageFromAgent:
             if (im.FromAgentID != OWNER)
             {
                 Self.InstantMessage(OWNER, string.Format("{0}:{1}", im.FromAgentName, im.Message));
             }
             break;
         case InstantMessageDialog.RequestTeleport:
             Self.TeleportLureRespond(im.FromAgentID, true);
             break;
     }
 }
Esempio n. 12
0
 public InstantMessageEventArgs(InstantMessage im, Simulator sim)
 {
     this.im = im;
     this.sim = sim;
 }