/// <summary>
 /// Convenience method for configuraing a callback channel.  Since this is not a duplex channel it doesn't
 /// support the declarative callbacks in the normal WCF method.
 /// </summary>
 /// <typeparam name="TContract"></typeparam>
 /// <returns></returns>
 public TContract GetCallback<TContract>()
 {
     ThrowIfDisposedOrNotOpen();
     try
     {
         Binding binding = channelListener.CreateResponseBinding();
         TContract channel = ChannelFactory<TContract>.CreateChannel(binding,new EndpointAddress(SsbUri.Default));
         SsbConversationSender sender = ((IClientChannel)channel).GetProperty<SsbConversationSender>();
         sender.SetConnection(con);
         ((IClientChannel)channel).Open();
         SsbConversationContext conversation = OperationContext.Current.IncomingMessageProperties[SsbConstants.SsbConversationMessageProperty] as SsbConversationContext;
         sender.OpenConversation(conversation.ConversationHandle);
         return channel;
     }
     catch (Exception ex)
     {
         throw new CommunicationException("An error occurred while obtaining callback channel: " + ex.Message, ex);
     }
 }
Пример #2
0
        public SsbOutputSessionChannel(SsbChannelFactory factory, string connectionString, Uri via, EndpointAddress remoteAddress, BufferManager buffermanager, MessageEncoder encoder, bool endConversationOnClose, string contract, bool useEncryption, bool useActionForSsbMessageType)
            : base(factory)
        {
            if (via == null)
            {
                throw new ArgumentNullException("via");
            }
            if (factory == null)
            {
                throw new ArgumentNullException("factory");
            }
            if (encoder == null)
            {
                throw new ArgumentNullException("encoder");
            }
            if (buffermanager == null)
            {
                throw new ArgumentNullException("bufferManager");
            }
            if (String.IsNullOrEmpty(connectionString))
            {
                throw new ArgumentNullException("connectionString");
            }
            this.factory                    = factory;
            this.via                        = via;
            this.to                         = remoteAddress;
            this.session                    = new SsbSession();
            this.encoder                    = encoder;
            this.bufferManager              = buffermanager;
            this.connectionString           = connectionString;
            this.contract                   = contract;
            this.useEncryption              = useEncryption;
            this.useActionForSsbMessageType = useActionForSsbMessageType;

            this.sender = new SsbConversationSender(connectionString, via, factory, endConversationOnClose, contract, useEncryption);
        }