public void DispatchRequest(IChannelRequest request)
        {
            _queue.Enqueue(request);
            _queueEvent.Set();

            CheckStartThread();
        }
 private void DoProcessRequests(IChannelRequest request)
 {
     try
     {
         Interlocked.Increment(ref _activeThreads);
         ProcessRequest(request);
         Interlocked.Decrement(ref _activeThreads);
     }
     catch (Exception e)
     {
         OnRequestException(request, e);
     }
 }
Exemplo n.º 3
0
        public void OpenConversationWithBuddy(string contactId, string message)
        {
            Contact contact = FindContact(contactId);

            ObjectPath         opath = new ObjectPath(EmpathyPlugin.CHANNELDISPATCHER_PATH);
            IChannelDispatcher iChannelDispatcherBus = Bus.Session.GetObject <IChannelDispatcher> (EmpathyPlugin.CHANNELDISPATCHER_IFACE, opath);

            Dictionary <string, object> channelRequestParameters = new Dictionary <string, object> ();

            channelRequestParameters.Add(EmpathyPlugin.CHANNEL_TYPE, EmpathyPlugin.CHANNEL_TYPE_TEXT);
            channelRequestParameters.Add(EmpathyPlugin.CHANNEL_TARGETHANDLETYPE, HandleType.Contact);
            channelRequestParameters.Add(EmpathyPlugin.CHANNEL_TARGETHANDLE, contact.ContactUInt);

            ObjectPath messageChannelPath = iChannelDispatcherBus.EnsureChannel(this.accountPath, channelRequestParameters, DateTime.Now.Ticks, "org.freedesktop.Telepathy.Client.Empathy");

            IChannelRequest iChannelRequest = Bus.Session.GetObject <IChannelRequest> (EmpathyPlugin.ACCOUNTMANAGER_IFACE, messageChannelPath);

            iChannelRequest.Proceed();

            if (message == null)
            {
                return;
            }

            foreach (ChannelInfo channelInfo in this.iConnection.ListChannels())
            {
                if (channelInfo.ChannelType == EmpathyPlugin.CHANNEL_TYPE_TEXT &&
                    channelInfo.HandleType == HandleType.Contact && channelInfo.Handle == contact.ContactUInt)
                {
                    IMessages messageChannel            = Bus.Session.GetObject <IMessages> (this.connectionBusIFace, channelInfo.Channel);
                    IDictionary <string, object> header = new Dictionary <string, object>()
                    {
                        { "message-type", ChannelTextMessageType.Notice }
                    };
                    IDictionary <string, object> alternative = new Dictionary <string, object>()
                    {
                        { "alternative", "main" },
                        { "content-type", "text/plain" },
                        { "content", message }
                    };
                    messageChannel.SendMessage(new IDictionary <string, object>[] { header, alternative }, MessageSendingFlags.None);
                }
            }
        }
 public abstract void OnRequestException(IChannelRequest request, Exception exception);
 public abstract void ProcessRequest(IChannelRequest request);