Пример #1
0
        public EndpointProxy GetEndpoint(Identity target, string uri, IDictionary <string, object> extras)
        {
            EndpointProxy e = this.GetEndpoint(target) ?? this.CreateProxy();

            e.Identity = target;
            // always clear, cached proxy will have broken channel
            e.Remove(uri);
            // always reget channel, make sure it's valid
            IClientChannel channel = this.ChannelSelector.GetChannel(new Uri(uri));
            // connect message
            Message msg = new Message();

            msg.MessageType = MessageType.CONNECT;
            IDictionary <string, object> content = new Dictionary <string, object>();

            this.Identity.Render(content);
            // pass extra data
            if (extras != null)
            {
                foreach (var p in extras)
                {
                    content.Add(p);
                }
            }
            msg.Content = content;
            this._handler.SendAndWait(e, channel, msg, TIMEOUT);
            e.Add(channel);
            return(e);
        }
Пример #2
0
        private EndpointProxy CreateProxy()
        {
            EndpointProxy e = new EndpointProxy(this._handler);

            this._connected.Add(e);
            return(e);
        }
Пример #3
0
        internal IDictionary <string, object> SendAndWait(EndpointProxy e
                                                          , IChannelSender sender
                                                          , Message message
                                                          , int timeout)
        {
            SendCallback callback = new SendCallback(e);

            this.Send(message, sender, callback);
            callback.WaitReturn(timeout);
            if (callback.Error != null)
            {
                throw callback.Error;
            }
            return(callback.Return);
        }
Пример #4
0
 public SendCallback(EndpointProxy endpointProxy)
 {
     this.Target  = endpointProxy;
     this._handle = new EventWaitHandle(false, EventResetMode.AutoReset);
 }