当前位置: 首页>>代码示例>>C#>>正文


C# OpenMetaverse.InstantMessageEventArgs类代码示例

本文整理汇总了C#中OpenMetaverse.InstantMessageEventArgs的典型用法代码示例。如果您正苦于以下问题:C# InstantMessageEventArgs类的具体用法?C# InstantMessageEventArgs怎么用?C# InstantMessageEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


InstantMessageEventArgs类属于OpenMetaverse命名空间,在下文中一共展示了InstantMessageEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Self_IM

        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;
                    }
//.........这里部分代码省略.........
开发者ID:RavenB,项目名称:gridsearch,代码行数:101,代码来源:InventoryManager.cs

示例2: Self_IM

        void Self_IM(object sender, InstantMessageEventArgs e)
        {
            bool groupIM = e.IM.GroupIM && GroupMembers != null && GroupMembers.ContainsKey(e.IM.FromAgentID) ? true : false;

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

                if (e.IM.Dialog == InstantMessageDialog.RequestTeleport)
                {
                    Console.WriteLine("Accepting teleport lure.");
                    Self.TeleportLureRespond(e.IM.FromAgentID, true);
                }
                else if (
                    e.IM.Dialog == InstantMessageDialog.MessageFromAgent ||
                    e.IM.Dialog == InstantMessageDialog.MessageFromObject)
                {
                    ClientManager.Instance.DoCommandAll(e.IM.Message, e.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})", e.IM.GroupIM ? "GroupIM" : "IM", e.IM.Dialog, e.IM.FromAgentName, e.IM.Message,
                    e.IM.RegionID, e.IM.Position);
                return;
            }
        }
开发者ID:RavenB,项目名称:gridsearch,代码行数:30,代码来源:TestClient.cs

示例3: FRTabWindow

        //private FriendsConsole fconsole;
        public FRTabWindow(METAboltInstance instance, InstantMessageEventArgs e)
        {
            InitializeComponent();

            this.instance = instance;
            //netcom = this.instance.Netcom;
            client = this.instance.Client;
            ProcessEventArgs(e);
        }
开发者ID:NullProjects,项目名称:METAbolt,代码行数:10,代码来源:FRTabWindow.cs

示例4: Self_IM

 static void Self_IM(object sender, InstantMessageEventArgs e)
 {
     if (e.IM.Dialog == InstantMessageDialog.RequestTeleport)
     {
         if (e.IM.FromAgentID == _MasterID)
         {
             _Client.Self.TeleportLureRespond(e.IM.FromAgentID, true);
         }
     }
 }
开发者ID:RavenB,项目名称:gridsearch,代码行数:10,代码来源:Program.cs

示例5: Self_IM

 void Self_IM(object sender, InstantMessageEventArgs e)
 {
     if (e.IM.Dialog == InstantMessageDialog.RequestTeleport)
     {
         this.BeginInvoke((MethodInvoker)delegate
         {
             DialogResult result = MessageBox.Show(this, e.IM.FromAgentName + " has offered you a teleport request:" + Environment.NewLine + e.IM.Message, this.Text, MessageBoxButtons.YesNo);
             if (result == DialogResult.Yes)
                 Client.Self.TeleportLureRespond(e.IM.FromAgentID, true);
         });
     }
 }
开发者ID:RavenB,项目名称:gridsearch,代码行数:12,代码来源:Dashboard.cs

示例6: IrcBot_IM

 private void IrcBot_IM(object sender, InstantMessageEventArgs im)
 {
     if (!client.IsRegionMaster)
     {
         return;
     }
     var e = im.IM;
     var type = e.Dialog;
     if (type == InstantMessageDialog.StartTyping || type == InstantMessageDialog.StopTyping) return;
     var message = e.Message;
     var id = e.FromAgentID;
     var fromname = e.FromAgentName;
     if (IrcCommand.IsChannelAgent(fromname)) return;
     if ((type == InstantMessageDialog.MessageFromAgent))
     {
         IrcCommand.IrcSend("" + fromname + ": " + message);
         return;
     }
     IrcCommand.IrcSend(fromname + " " + type + ": " + message);     
 }
开发者ID:drzo,项目名称:opensim4opencog,代码行数:20,代码来源:IrcBotModule.cs

示例7: Self_IM

        void Self_IM(object sender, InstantMessageEventArgs e)
        {
            // Every event coming from a different thread (almost all of them, most certanly those
            // from libomv) needs to be executed on the GUI thread. This code can be basically
            // copy-pasted on the begining of each libomv event handler that results in update
            // of any GUI element
            //
            // In this case the IM we sent back as a reply is also displayed in the corresponding IM tab
            if (Instance.MainForm.InvokeRequired)
            {
                Instance.MainForm.BeginInvoke(new MethodInvoker(() => Self_IM(sender, e)));
                return;
            }

            // We need to filter out all sorts of things that come in as a instante message
            if (e.IM.Dialog == InstantMessageDialog.MessageFromAgent // Message is not notice, inv. offer, etc etc
                && !Instance.Groups.ContainsKey(e.IM.IMSessionID)  // Message is not group IM (sessionID == groupID)
                && e.IM.BinaryBucket.Length < 2                    // Session is not ad-hoc friends conference
                && e.IM.FromAgentName != "Second Life"             // Not a system message
                )
            {
                if (e.IM.Message == "demo plugin version")
                {
                    Instance.Netcom.SendInstantMessage(
                        string.Format("Hello {0}, my version is {1}", e.IM.FromAgentName, version),
                        e.IM.FromAgentID,
                        e.IM.IMSessionID);
                }
            }
        }
开发者ID:RevolutionSmythe,项目名称:radegast,代码行数:30,代码来源:DemoPlugin.cs

示例8: OnInstantMessage

        /// <summary>
        /// Handle Instant Messages
        /// </summary>
        /// <param name="im"></param>
        /// <param name="simulator"></param>
        void OnInstantMessage(object sender, InstantMessageEventArgs e)
        {
            ThreadPool.QueueUserWorkItem(sync =>
                {
                    Thread.Sleep(100); // Give tab a chance to show up
                    Conversation.IMSession sess = null;
                    string groupName;

                    // All sorts of things come in as a instant messages. For actual messages
                    // we need to match them up with an existing Conversation.  IM Conversations
                    // are keyed by the name of the group or individual involved.
                    switch (e.IM.Dialog)
                    {
                        case InstantMessageDialog.MessageFromAgent:
                            if (control.instance.Groups.ContainsKey(e.IM.IMSessionID))
                            {
                                // Message from a group member
                                groupName = control.instance.Groups[e.IM.IMSessionID].Name;
                                sess = (IMSession)control.converse.GetConversation(groupName);
                                if (sess != null)
                                    sess.OnMessage(e.IM.FromAgentID, e.IM.FromAgentName, e.IM.Message);
                                else
                                    Talker.Say(e.IM.FromAgentName + ", " + e.IM.Message);
                            }
                            else if (e.IM.BinaryBucket.Length >= 2)
                            {
                                // Ad-hoc friend conference
                                sess = (IMSession)control.converse.GetConversation(Utils.BytesToString(e.IM.BinaryBucket));
                                if (sess != null)
                                    sess.OnMessage(e.IM.FromAgentID, e.IM.FromAgentName, e.IM.Message);
                                else
                                    Talker.Say(e.IM.FromAgentName + ", " + e.IM.Message);
                            }
                            else if (e.IM.FromAgentName == "Second Life")
                            {
                                Talker.Say("Second Life says " + e.IM.Message);
                            }
                            else
                            {
                                // Message from an individual
                                sess = (IMSession)control.converse.GetConversation(e.IM.FromAgentName);
                                if (sess != null)
                                    sess.OnMessage(e.IM.FromAgentID, e.IM.FromAgentName, e.IM.Message);
                                else
                                    Talker.Say(e.IM.FromAgentName + ", " + e.IM.Message);
                            }
                            break;

                        case InstantMessageDialog.SessionSend:
                            if (control.instance.Groups.ContainsKey(e.IM.IMSessionID))
                            {
                                // Message from a group member
                                groupName = control.instance.Groups[e.IM.IMSessionID].Name;
                                sess = (IMSession)control.converse.GetConversation(groupName);
                            }
                            else if (e.IM.BinaryBucket.Length >= 2) // ad hoc friends conference
                            {
                                sess = (IMSession)control.converse.GetConversation(Utils.BytesToString(e.IM.BinaryBucket));
                            }

                            if (sess != null)
                                sess.OnMessage(e.IM.FromAgentID, e.IM.FromAgentName, e.IM.Message);
                            break;

                        case InstantMessageDialog.FriendshipOffered:
                            Talker.Say(e.IM.FromAgentName + " is offering friendship.");
                            break;

                        default:
                            break;
                    }
                }
            );
        }
开发者ID:Nuriat,项目名称:radegast,代码行数:79,代码来源:Control.cs

示例9: Self_IM

        void Self_IM(object sender, InstantMessageEventArgs e)
        {
            // Every event coming from a different thread (almost all of them, most certanly those
            // from libomv) needs to be executed on the GUI thread. This code can be basically
            // copy-pasted on the begining of each libomv event handler that results in update
            // of any GUI element
            //
            // In this case the IM we sent back as a reply is also displayed in the corresponding IM tab
            if (Instance.MainForm.InvokeRequired)
            {
                Instance.MainForm.BeginInvoke(
                    new MethodInvoker(
                        delegate()
                        {
                            Self_IM(sender, e);
                        }
                        ));
                return;
            }

            // We need to filter out all sorts of things that come in as a instante message
            if (e.IM.Dialog == InstantMessageDialog.MessageFromAgent // Message is not notice, inv. offer, etc etc
                && !Instance.Groups.ContainsKey(e.IM.IMSessionID)  // Message is not group IM (sessionID == groupID)
                && e.IM.BinaryBucket.Length < 2                    // Session is not ad-hoc friends conference
                && e.IM.FromAgentName != "Second Life"             // Not a system message
                && Alice.isAcceptingUserInput                    // Alice bot loaded successfully
                && Enabled                                       // Alice bot is enabled
                )
            {
                ThreadPool.QueueUserWorkItem(sync =>
                {
                    lock (syncChat)
                    {
                        Alice.GlobalSettings.updateSetting("location", "region " + Client.Network.CurrentSim.Name);
                        AIMLbot.User user;
                        if (AliceUsers.ContainsKey(e.IM.FromAgentName))
                        {
                            user = (AIMLbot.User)AliceUsers[e.IM.FromAgentName];
                        }
                        else
                        {
                            user = new User(e.IM.FromAgentName, Alice);
                            user.Predicates.removeSetting("name");
                            user.Predicates.addSetting("name", FirstName(e.IM.FromAgentName));
                            AliceUsers[e.IM.FromAgentName] = user;
                        }
                        AIMLbot.Request req = new Request(e.IM.Message, user, Alice);
                        AIMLbot.Result res = Alice.Chat(req);
                        string msg = res.Output;
                        if (msg.Length > 1000)
                        {
                            msg = msg.Substring(0, 1000);
                        }
                        if (EnableRandomDelay) System.Threading.Thread.Sleep(2000 + 1000 * rand.Next(3));
                        Instance.Netcom.SendIMStartTyping(e.IM.FromAgentID, e.IM.IMSessionID);
                        if (EnableRandomDelay)
                        {
                            System.Threading.Thread.Sleep(2000 + 1000 * rand.Next(5));
                        }
                        else
                        {
                            System.Threading.Thread.Sleep(1000);
                        }
                        Instance.Netcom.SendIMStopTyping(e.IM.FromAgentID, e.IM.IMSessionID);
                        if (Instance.MainForm.InvokeRequired)
                        {
                            Instance.MainForm.BeginInvoke(new MethodInvoker(() => Instance.Netcom.SendInstantMessage(msg, e.IM.FromAgentID, e.IM.IMSessionID)));
                        }
                        else
                        {
                            Instance.Netcom.SendInstantMessage(msg, e.IM.FromAgentID, e.IM.IMSessionID);
                        }
                    }
                });
            }
        }
开发者ID:Nuriat,项目名称:radegast,代码行数:76,代码来源:Alice.cs

示例10: HandleGroupIM

        private void HandleGroupIM(InstantMessageEventArgs e)
        {
            // Ignore group IM from a muted group
            if (null != client.Self.MuteList.Find(me => me.Type == MuteType.Group && (me.ID == e.IM.IMSessionID || me.ID == e.IM.FromAgentID))) return;

            if (TabExists(e.IM.IMSessionID.ToString()))
            {
                RadegastTab tab = tabs[e.IM.IMSessionID.ToString()];
                if (!tab.Selected) tab.Highlight();
                return;
            }

            instance.MediaManager.PlayUISound(UISounds.IM);

            GroupIMTabWindow imTab = AddGroupIMTab(e);
            tabs[e.IM.IMSessionID.ToString()].Highlight();
        }
开发者ID:robincornelius,项目名称:radegast,代码行数:17,代码来源:TabsConsole.cs

示例11: Self_IM

 void Self_IM(object sender, InstantMessageEventArgs e)
 {
     if (CanSyncInvoke)
         netcomSync.BeginInvoke(new OnInstantMessageRaise(OnInstantMessageReceived), new object[] { e });
     else
         OnInstantMessageReceived(e);
 }
开发者ID:RevolutionSmythe,项目名称:radegast,代码行数:7,代码来源:SLNetCom.cs

示例12: netcom_InstantMessageReceived

        private void netcom_InstantMessageReceived(object sender, InstantMessageEventArgs e)
        {
            if (e.IM.IMSessionID != sessionID) return;
            if (e.IM.Dialog == InstantMessageDialog.StartTyping ||
                e.IM.Dialog == InstantMessageDialog.StopTyping)
                return;

            textBuffer.Add(e);
            ProcessIM(e);
        }
开发者ID:TooheyPaneer,项目名称:radegast,代码行数:10,代码来源:IMTextManager.cs

示例13: Self_IM

        static void Self_IM(object sender, InstantMessageEventArgs e)
        {
            if (e.IM.Message == "acierto")
            {
                System.Threading.Thread.Sleep(3000);
                Program.bot.decir("Vielen Dank " + Program.bot.nombre_camarero);
                System.Threading.Thread.Sleep(3000);
                Program.bot.cliente.Self.Chat("servido", CANAL_BOT2, OpenMetaverse.ChatType.Shout);

                System.Threading.Thread.Sleep(1000);
                Program.bot.ejecutarGesto(Program.bot.CELEBRACION);
                Program.consola.escribeMensaje("El camarero ha realizado la entrega bien.");
                //Program.bot.estado = 0;
                Program.bot.dejar_atender(); // Deja libre al bot.
            }
            else if (e.IM.Message == "fallo")
            {
                System.Threading.Thread.Sleep(3000);
                Program.bot.decir("Vielen Dank " + Program.bot.nombre_camarero + ", aber die Bestellung ist nicht korrekt.");
                System.Threading.Thread.Sleep(3000);
                Program.bot.cliente.Self.Chat("servido", CANAL_BOT2, OpenMetaverse.ChatType.Shout);

                System.Threading.Thread.Sleep(1000);
                Program.bot.ejecutarGesto(Program.bot.NO);
                Program.consola.escribeMensaje("El camarero ha realizado la entrega mal.");
                Program.bot.dejar_atender(); // Deja libre al bot.
            }
            else
            {
                string csv = e.IM.Message;
                string[] parts = csv.Split(',');

                int tam = parts.GetLength(0);

                if (tam > 1)
                {
                    if (parts[0] == "start")
                    {
                        Program.bot.activo = true;
                        Program.bot.setCamarero((UUID)parts[1], parts[2]);
                        Program.bot.gritar(Program.bot.nombre_camarero + " Entschuldige bitte!");
                        while (Program.bot.estado != 1 && Program.bot.activo != false)
                        {
                            Program.bot.cliente.Self.AnimationStart(Animations.HELLO, true);
                            System.Threading.Thread.Sleep(1000);
                            Program.bot.cliente.Self.AnimationStop(Animations.HELLO, true);
                            System.Threading.Thread.Sleep(1000);
                        }
                    }
                    else if (parts[0] == "resetear")
                    {
                        Program.bot.activo = false;
                        Program.bot.decir(Program.bot.nombre_camarero + " Jetzt habe ich keinen Appetit mehr!!!");
                        Program.bot.dejar_atender();
                    }
                }
                else
                {
                    Program.bot.silla = new UUID(e.IM.Message);
                }
            }
        }
开发者ID:raulgomezsa,项目名称:deutsch-gefe,代码行数:62,代码来源:Program.cs

示例14: ProcessIM

        /// <summary>
        /// Dispatcher for incoming IM automation
        /// </summary>
        /// <param name="e">Incoming message</param>
        /// <returns>If message processed correctly, should GUI processing be halted</returns>
        public bool ProcessIM(InstantMessageEventArgs e)
        {
            LoadSettings();

            if (!Enabled)
            {
                return false;
            }

            switch (e.IM.Dialog)
            {
                case InstantMessageDialog.MessageFromObject:
                    {
                        if (e.IM.FromAgentID != AllowedOwner)
                        {
                            return true;
                        }
                        string[] args = e.IM.Message.Trim().Split('^');
                        if (args.Length < 1) return false;

                        switch (args[0].Trim())
                        {
                            case "group_invite":
                                {
                                    if (args.Length < 4) return false;
                                    ProcessInvite(args);
                                    return true;
                                }
                            case "send_im":
                                {
                                    if (args.Length < 3) return false;
                                    UUID sendTo = UUID.Zero;
                                    if (!UUID.TryParse(args[1].Trim(), out sendTo)) return false;
                                    string msg = args[2].Trim();
                                    client.Self.InstantMessage(sendTo, msg);
                                    return true;
                                }
                            case "give_inventory":
                                {
                                    if (args.Length < 3) return false;
                                    UUID sendTo = UUID.Zero;
                                    UUID invItemID = UUID.Zero;
                                    if (!UUID.TryParse(args[1].Trim(), out sendTo)) return false;
                                    if (!UUID.TryParse(args[2].Trim(), out invItemID)) return false;
                                    if (!client.Inventory.Store.Contains(invItemID))
                                    {
                                        instance.TabConsole.DisplayNotificationInChat(
                                            string.Format("Tried to offer {0} but could not find it in my inventory", invItemID),
                                            ChatBufferTextStyle.Error);
                                        return false;
                                    }
                                    InventoryItem item = client.Inventory.Store[invItemID] as InventoryItem;
                                    if (item == null)
                                        return false;
                                    client.Inventory.GiveItem(item.UUID, item.Name, item.AssetType, sendTo, true);
                                    WorkPool.QueueUserWorkItem(sync =>
                                        instance.TabConsole.DisplayNotificationInChat(
                                            string.Format("Gave {0} to {1}", item.Name, instance.Names.Get(sendTo, true)),
                                            ChatBufferTextStyle.ObjectChat)
                                    );
                                    return true;
                                }
                        }
                    }
                    break;
            }

            return false;
        }
开发者ID:Booser,项目名称:radegast,代码行数:74,代码来源:LSLHelper.cs

示例15: ProcessEventArgs

        private void ProcessEventArgs(InstantMessageEventArgs e)
        {
            targetName = e.IM.FromAgentName;
            targetUUID = e.IM.FromAgentID;
            isession = e.IM.IMSessionID;

            lblSubheading.Text =
                "You have received a Friendship invite from " + targetName + "";

            //rtbOfferMessage.AppendText(e.IM.Message);
        }
开发者ID:NullProjects,项目名称:METAbolt,代码行数:11,代码来源:FRTabWindow.cs


注:本文中的OpenMetaverse.InstantMessageEventArgs类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。