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


C# IClientAPI.SendInstantMessage方法代码示例

本文整理汇总了C#中IClientAPI.SendInstantMessage方法的典型用法代码示例。如果您正苦于以下问题:C# IClientAPI.SendInstantMessage方法的具体用法?C# IClientAPI.SendInstantMessage怎么用?C# IClientAPI.SendInstantMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IClientAPI的用法示例。


在下文中一共展示了IClientAPI.SendInstantMessage方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnInstantMessage

        public void OnInstantMessage(IClientAPI client, GridInstantMessage im)
        {
            byte dialog = im.dialog;

            if (client != null && dialog == (byte)InstantMessageDialog.MessageFromAgent)
                LogInstantMesssage(im);

            if (dialog != (byte)InstantMessageDialog.MessageFromAgent
                && dialog != (byte)InstantMessageDialog.StartTyping
                && dialog != (byte)InstantMessageDialog.StopTyping
                && dialog != (byte)InstantMessageDialog.BusyAutoResponse
                && dialog != (byte)InstantMessageDialog.MessageFromObject)
            {
                return;
            }

            //DateTime dt = DateTime.UtcNow;

            // Ticks from UtcNow, but make it look like local. Evil, huh?
            //dt = DateTime.SpecifyKind(dt, DateTimeKind.Local);

            //try
            //{
            //    // Convert that to the PST timezone
            //    TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles");
            //    dt = TimeZoneInfo.ConvertTime(dt, timeZoneInfo);
            //}
            //catch
            //{
            //    //m_log.Info("[OFFLINE MESSAGING]: No PST timezone found on this machine. Saving with local timestamp.");
            //}

            //// And make it look local again to fool the unix time util
            //dt = DateTime.SpecifyKind(dt, DateTimeKind.Utc);

            // If client is null, this message comes from storage and IS offline
            if (client != null)
                im.offline = 0;

            if (im.offline == 0)
                im.timestamp = (uint)Util.UnixTimeSinceEpoch();

            if (m_TransferModule != null)
            {
                if (client != null)
                    im.fromAgentName = client.FirstName + " " + client.LastName;
                m_TransferModule.SendInstantMessage(im,
                    delegate(bool success)
                    {
                        if (dialog == (uint)InstantMessageDialog.StartTyping ||
                            dialog == (uint)InstantMessageDialog.StopTyping ||
                            dialog == (uint)InstantMessageDialog.MessageFromObject)
                        {
                            return;
                        }

                        if ((client != null) && !success)
                        {
                            client.SendInstantMessage(
                                    new GridInstantMessage(
                                    null, new UUID(im.fromAgentID), "System",
                                    new UUID(im.toAgentID),
                                    (byte)InstantMessageDialog.BusyAutoResponse,
                                    "Unable to send instant message. "+
                                    "User is not logged in.", false,
                                    new Vector3()));
                        }
                    }
                );
            }
        }
开发者ID:CassieEllen,项目名称:opensim,代码行数:71,代码来源:InstantMessageModule.cs

示例2: RetrieveInstantMessages

        private void RetrieveInstantMessages(IClientAPI client)
        {
            m_log.DebugFormat("[OfflineIM.V2]: Retrieving stored messages for {0}", client.AgentId);

            List<GridInstantMessage> msglist = m_OfflineIMService.GetMessages(client.AgentId);

            if (msglist == null)
                m_log.DebugFormat("[OfflineIM.V2]: WARNING null message list.");

            foreach (GridInstantMessage im in msglist)
            {
                if (im.dialog == (byte)InstantMessageDialog.InventoryOffered)
                    // send it directly or else the item will be given twice
                    client.SendInstantMessage(im);
                else
                {
                    // Send through scene event manager so all modules get a chance
                    // to look at this message before it gets delivered.
                    //
                    // Needed for proper state management for stored group
                    // invitations
                    //
                    Scene s = FindScene(client.AgentId);
                    if (s != null)
                        s.EventManager.TriggerIncomingInstantMessage(im);
                }
            }
        }
开发者ID:AkiraSonoda,项目名称:akisim,代码行数:28,代码来源:OfflineIMRegionModule.cs

示例3: ProcessMessageFromGroupSession

        private void ProcessMessageFromGroupSession(GridInstantMessage msg, IClientAPI client)
        {
            if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Session message from {0} going to agent {1}", msg.fromAgentName, msg.toAgentID);

            UUID AgentID = new UUID(msg.fromAgentID);
            UUID GroupID = new UUID(msg.imSessionID);

            switch (msg.dialog)
            {
                case (byte)InstantMessageDialog.SessionAdd:
                    m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);
                    break;

                case (byte)InstantMessageDialog.SessionDrop:
                    m_groupData.AgentDroppedFromGroupChatSession(AgentID, GroupID);
                    break;

                case (byte)InstantMessageDialog.SessionSend:
                    if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID, GroupID)
                        && !m_groupData.hasAgentBeenInvitedToGroupChatSession(AgentID, GroupID)
                        )
                    {
                        // Agent not in session and hasn't dropped from session
                        // Add them to the session for now, and Invite them
                        m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);

                        UUID toAgentID = new UUID(msg.toAgentID);

                        GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null);
                        if (groupInfo != null)
                        {
                            if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Sending chatterbox invite instant message");

                            // Force? open the group session dialog???
                            // and simultanously deliver the message, so we don't need to do a seperate client.SendInstantMessage(msg);
                            IEventQueue eq = client.Scene.RequestModuleInterface<IEventQueue>();
                            eq.ChatterboxInvitation(
                                GroupID
                                , groupInfo.GroupName
                                , new UUID(msg.fromAgentID)
                                , msg.message
                                , new UUID(msg.toAgentID)
                                , msg.fromAgentName
                                , msg.dialog
                                , msg.timestamp
                                , msg.offline == 1
                                , (int)msg.ParentEstateID
                                , msg.Position
                                , 1
                                , new UUID(msg.imSessionID)
                                , msg.fromGroup
                                , Utils.StringToBytes(groupInfo.GroupName)
                                );

                            eq.ChatterBoxSessionAgentListUpdates(
                                new UUID(GroupID)
                                , new UUID(msg.fromAgentID)
                                , new UUID(msg.toAgentID)
                                , false //canVoiceChat
                                , false //isModerator
                                , false //text mute
                                );
                        }

                        break;
                    }
                    else if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID, GroupID))
                    {
                        // User hasn't dropped, so they're in the session, 
                        // maybe we should deliver it.
                        client.SendInstantMessage(msg);
                    }

                    break;

                default:
                    client.SendInstantMessage(msg);

                    break;;
            }
        }
开发者ID:JamesStallings,项目名称:opensimulator,代码行数:81,代码来源:GroupsMessagingModule.cs

示例4: RetrieveInstantMessages

        private void RetrieveInstantMessages(IClientAPI client)
        {
            if (m_RestURL == String.Empty)
            {
                return;
            }
            else
            {
                m_log.DebugFormat("[OFFLINE MESSAGING]: Retrieving stored messages for {0}", client.AgentId);

                List<GridInstantMessage> msglist
                    = SynchronousRestObjectRequester.MakeRequest<UUID, List<GridInstantMessage>>(
                        "POST", m_RestURL + "/RetrieveMessages/", client.AgentId);

                if (msglist != null)
                {
                    foreach (GridInstantMessage im in msglist)
                    {
                        if (im.dialog == (byte)InstantMessageDialog.InventoryOffered)
                            // send it directly or else the item will be given twice
                            client.SendInstantMessage(im);
                        else
                        {
                            // Send through scene event manager so all modules get a chance
                            // to look at this message before it gets delivered.
                            //
                            // Needed for proper state management for stored group
                            // invitations
                            //

                            im.offline = 1;

                            Scene s = FindScene(client.AgentId);
                            if (s != null)
                                s.EventManager.TriggerIncomingInstantMessage(im);
                        }
                    }
                }
            }
        }
开发者ID:CassieEllen,项目名称:opensim,代码行数:40,代码来源:OfflineMessageModule.cs

示例5: OnInstantMessage

        public void OnInstantMessage(IClientAPI client, GridInstantMessage im)
        {
            byte dialog = im.dialog;

            if (dialog != (byte)InstantMessageDialog.MessageFromAgent
                && dialog != (byte)InstantMessageDialog.StartTyping
                && dialog != (byte)InstantMessageDialog.StopTyping
                && dialog != (byte)InstantMessageDialog.BusyAutoResponse
                && dialog != (byte)InstantMessageDialog.MessageFromObject)
            {
                return;
            }

            if (m_TransferModule != null)
            {
                if (client != null)
                    im.fromAgentName = client.FirstName + " " + client.LastName;
                m_TransferModule.SendInstantMessage(im,
                    delegate(bool success)
                    {
                        if (dialog == (uint)InstantMessageDialog.StartTyping ||
                            dialog == (uint)InstantMessageDialog.StopTyping ||
                            dialog == (uint)InstantMessageDialog.MessageFromObject)
                        {
                            return;
                        }

                        if ((client != null) && !success)
                        {
                            client.SendInstantMessage(
                                    new GridInstantMessage(
                                    null, new UUID(im.fromAgentID), "System",
                                    new UUID(im.toAgentID),
                                    (byte)InstantMessageDialog.BusyAutoResponse,
                                    "Unable to send instant message. "+
                                    "User is not logged in.", false,
                                    new Vector3()));
                        }
                    }
                );
            }
        }
开发者ID:RadaSangOn,项目名称:workCore2,代码行数:42,代码来源:InstantMessageModule.cs

示例6: OnInstantMessage

        public void OnInstantMessage(IClientAPI client, GridInstantMessage im)
        {
            byte dialog = im.dialog;

            if (dialog != (byte)InstantMessageDialog.MessageFromAgent
                && dialog != (byte)InstantMessageDialog.StartTyping
                && dialog != (byte)InstantMessageDialog.StopTyping
                && dialog != (byte)InstantMessageDialog.BusyAutoResponse
                && dialog != (byte)InstantMessageDialog.MessageFromObject)
            {
                return;
            }

            if (m_TransferModule != null)
            {
				// CyberSecurity chat logging
				if (client != null)
				{
					im.fromAgentName = client.FirstName + " " + client.LastName;

					if(!im.message.Equals("typing"))
					{
						// Look up user accounts
						UserAccount toAccount = getAccountByUUID(im.toAgentID);
						UserAccount fromAccount = getAccountByUUID(im.fromAgentID);

						string toAgentName = null;
						if (toAccount != null)
						{
							toAgentName = toAccount.Name;
						}
						else
						{
							toAgentName = im.toAgentID.ToString();
						}

						// Log the chat
						//TODO: Get the actual position of the from account
						Chat.CyberSecurityChatLogger.logChat(null, im.message, Vector3.Zero, im.fromAgentName, toAgentName, m_scenes[0].RegionInfo.RegionName, new UUID(im.fromAgentID), new UUID(im.toAgentID));
					}
				}

                m_TransferModule.SendInstantMessage(im,
                    delegate(bool success)
                    {
                        if (dialog == (uint)InstantMessageDialog.StartTyping ||
                            dialog == (uint)InstantMessageDialog.StopTyping ||
                            dialog == (uint)InstantMessageDialog.MessageFromObject)
                        {
                            return;
                        }

                        if ((client != null) && !success)
                        {
                            client.SendInstantMessage(
                                    new GridInstantMessage(
                                    null, new UUID(im.fromAgentID), "System",
                                    new UUID(im.toAgentID),
                                    (byte)InstantMessageDialog.BusyAutoResponse,
                                    "Unable to send instant message. "+
                                    "User is not logged in.", false,
                                    new Vector3()));
                        }
                    }
                );
            }
        }
开发者ID:HOLOGRAPHICpizza,项目名称:VDC-OpenSim,代码行数:67,代码来源:InstantMessageModule.cs

示例7: SendEntryMessage

        private void SendEntryMessage(IClientAPI client)
        {
            GridInstantMessage msg = new GridInstantMessage();
            msg.imSessionID = UUID.Zero.Guid;
            msg.fromAgentID = UUID.Zero.Guid;
            msg.toAgentID = client.AgentId.Guid;
            msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
            msg.fromAgentName = "System";
            msg.message = m_messageOnEntry;
            msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.ConsoleAndChatHistory;
            msg.fromGroup = false;
            msg.offline = (byte)0;
            msg.ParentEstateID = 0;
            msg.Position = Vector3.Zero;
            msg.RegionID = UUID.Zero.Guid;
            msg.binaryBucket = new byte[0];

            client.SendInstantMessage(msg);
        }
开发者ID:EnricoNirvana,项目名称:BitCoin4OpenSim,代码行数:19,代码来源:FreeMoneyModule.cs

示例8: OnInstantMessage

        public void OnInstantMessage(IClientAPI client, GridInstantMessage im)
        {
            byte dialog = im.dialog;

            if (dialog != (byte)InstantMessageDialog.MessageFromAgent
                && dialog != (byte)InstantMessageDialog.StartTyping
                && dialog != (byte)InstantMessageDialog.StopTyping
                && dialog != (byte)InstantMessageDialog.MessageFromObject)
            {
                return;
            }

            if (m_TransferModule != null)
            {
                if (client == null)
                {
                    UserAccount account = m_scenes[0].UserAccountService.GetUserAccount(m_scenes[0].RegionInfo.ScopeID, new UUID(im.fromAgentID));
                    if (account != null)
                        im.fromAgentName = account.Name;
                    else
                        im.fromAgentName = im.fromAgentName + "(No account found for this user)";
                }
                else
                    im.fromAgentName = client.Name;

                m_TransferModule.SendInstantMessage(im,
                    delegate(bool success)
                    {
                        if (dialog == (uint)InstantMessageDialog.StartTyping ||
                            dialog == (uint)InstantMessageDialog.StopTyping ||
                            dialog == (uint)InstantMessageDialog.MessageFromObject)
                        {
                            return;
                        }

                        if ((client != null) && !success)
                        {
                            client.SendInstantMessage(
                                    new GridInstantMessage(
                                    null, new UUID(im.fromAgentID), "System",
                                    new UUID(im.toAgentID),
                                    (byte)InstantMessageDialog.BusyAutoResponse,
                                    "Unable to send instant message. "+
                                    "User is not logged in.", false,
                                    new Vector3()));
                        }
                    }
                );
            }
        }
开发者ID:kow,项目名称:Aurora-Sim,代码行数:50,代码来源:InstantMessageModule.cs

示例9: ProcessMessageFromGroupSession

        private void ProcessMessageFromGroupSession(GridInstantMessage msg, IClientAPI client)
        {
            if (m_debugEnabled) 
                m_log.DebugFormat(
                    "[GROUPS-MESSAGING]: Session message from {0} going to agent {1}, sessionID {2}, type {3}",
                    msg.fromAgentName, msg.toAgentID, msg.imSessionID, (InstantMessageDialog)msg.dialog);

            UUID fromAgentID = new UUID(msg.fromAgentID);
            UUID GroupID = new UUID(msg.imSessionID);
            IEventQueue eq = client.Scene.RequestModuleInterface<IEventQueue>();

            switch (msg.dialog)
            {
                case (byte)InstantMessageDialog.SessionAdd:
                    m_groupData.AgentInvitedToGroupChatSession(fromAgentID, GroupID);
                    if(eq != null)
                        eq.ChatterBoxSessionAgentListUpdates(
                            GroupID
                            , fromAgentID
                            , client.AgentId
                            , false //canVoiceChat
                            , false //isModerator
                            , false //text mute
                            , true // enter
                            );
                    break;

                case (byte)InstantMessageDialog.SessionDrop:
                    m_groupData.AgentDroppedFromGroupChatSession(fromAgentID, GroupID);
                    if(eq != null)
                        eq.ChatterBoxSessionAgentListUpdates(
                                GroupID
                                , fromAgentID
                                , client.AgentId
                                , false //canVoiceChat
                                , false //isModerator
                                , false //text mute
                                , false // leave
                                );
                    break;

                case (byte)InstantMessageDialog.SessionSend:
                    if (!m_groupData.hasAgentDroppedGroupChatSession(client.AgentId, GroupID))
                    {
                        if(!m_groupData.hasAgentBeenInvitedToGroupChatSession(client.AgentId, GroupID))
                        {

                            GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null);
                            if (groupInfo != null)
                            {
                                if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Sending chatterbox invite instant message");

                                if(eq != null)
                                {
                                    eq.ChatterboxInvitation(
                                        GroupID
                                        , groupInfo.GroupName
                                        , fromAgentID
                                        , msg.message
                                        , client.AgentId
                                        , msg.fromAgentName
                                        , msg.dialog
                                        , msg.timestamp
                                        , msg.offline == 1
                                        , (int)msg.ParentEstateID
                                        , msg.Position
                                        , 1
                                        , new UUID(msg.imSessionID)
                                        , msg.fromGroup
                                        , Utils.StringToBytes(groupInfo.GroupName)
                                        );
                                }
                            }
                        }
                        else 
                        {
                            client.SendInstantMessage(msg);
                        }

//                        if (!m_groupData.hasAgentBeenInvitedToGroupChatSession(fromAgentID, GroupID))
                        {
                             m_groupData.AgentInvitedToGroupChatSession(fromAgentID, GroupID);
                             eq.ChatterBoxSessionAgentListUpdates(
                                    GroupID
                                    , fromAgentID
                                    , client.AgentId
                                    , false //canVoiceChat
                                    , false //isModerator
                                    , false //text mute
                                    , true // enter
                                    );
                        }
                    }
                    break;

                default:
                    client.SendInstantMessage(msg);
                    break;;
            }
        }
开发者ID:emperorstarfinder,项目名称:Opensim2,代码行数:100,代码来源:GroupsMessagingModule.cs

示例10: RetrieveInstantMessages

        private void RetrieveInstantMessages(IClientAPI client)
        {
            if (OfflineMessagesConnector == null)
                return;
            MainConsole.Instance.DebugFormat("[OFFLINE MESSAGING] Retrieving stored messages for {0}", client.AgentId);

            List<GridInstantMessage> msglist = OfflineMessagesConnector.GetOfflineMessages(client.AgentId);
            msglist.Sort(delegate(GridInstantMessage a, GridInstantMessage b)
            {
                return a.timestamp.CompareTo(b.timestamp);
            });
            foreach (GridInstantMessage IM in msglist)
            {
                if (IM.dialog == (byte)InstantMessageDialog.InventoryOffered)
                    client.SendInstantMessage(IM);
                else
                {

                    // Send through scene event manager so all modules get a chance
                    // to look at this message before it gets delivered.
                    //
                    // Needed for proper state management for stored group
                    // invitations
                    //
                    IM.offline = 1;
                    IScene s = FindScene(client.AgentId);
                    if (s != null)
                        s.EventManager.TriggerIncomingInstantMessage(IM);
                }
            }
        }
开发者ID:BillyWarrhol,项目名称:Aurora-Sim,代码行数:31,代码来源:AuroraOfflineMessagesModule.cs


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