コード例 #1
0
        public ITransport CompositeConnect(Uri location, SetTransport setTransport)
        {
            // Extract query parameters from broker Uri
            StringDictionary map = URISupport.ParseQuery(location.Query);

            // Set transport. properties on this (the factory)
            URISupport.SetProperties(this, map, "transport.");

            Tracer.Debug("Opening socket to: " + location.Host + " on port: " + location.Port);
            Socket socket = Connect(location.Host, location.Port);

#if !NETCF
            socket.ReceiveBufferSize = ReceiveBufferSize;
            socket.SendBufferSize    = SendBufferSize;
            socket.ReceiveTimeout    = ReceiveTimeout;
            socket.SendTimeout       = SendTimeout;
#endif

            IWireFormat wireformat = CreateWireFormat(map);
            ITransport  transport  = new TcpTransport(location, socket, wireformat);

            wireformat.Transport = transport;

            if (UseLogging)
            {
                transport = new LoggingTransport(transport);
            }

            if (UseInactivityMonitor)
            {
                transport = new InactivityMonitor(transport);
            }

            if (wireformat is OpenWireFormat)
            {
                transport = new WireFormatNegotiator(transport, (OpenWireFormat)wireformat);
            }

            transport.RequestTimeout = this.requestTimeout;

            if (setTransport != null)
            {
                setTransport(transport, location);
            }

            return(transport);
        }
コード例 #2
0
ファイル: FailoverTransport.cs プロジェクト: Redi0/meijing-ui
 /// <summary>
 /// Initializes a new instance of the <see cref="Connector"/> class.
 /// </summary>
 /// <param name="setTransport">The set transport.</param>
 /// <param name="uri">The URI.</param>
 /// <param name="transport">The transport.</param>
 public Connector(SetTransport setTransport, Uri uri, FailoverTransport transport)
 {
     _uri = uri;
     _setTransport = setTransport;
     _transport = transport;
 }
コード例 #3
0
 public ITransport CompositeConnect(Uri location, SetTransport setTransport)
 {
     return(CreateTransport(location));
 }
コード例 #4
0
        public static ITransport AsyncCompositeConnect(Uri location, SetTransport setTransport)
        {
            ITransportFactory tf = TransportFactory.CreateTransportFactory(location);

            return(tf.CompositeConnect(location, setTransport));
        }
コード例 #5
0
 public ITransport CompositeConnect(Uri location, SetTransport setTransport)
 {
     throw new NMSConnectionException("Asynchronous composite connection not supported with Mock transport.");
 }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Connector"/> class.
 /// </summary>
 /// <param name="setTransport">The set transport.</param>
 /// <param name="uri">The URI.</param>
 /// <param name="transport">The transport.</param>
 public Connector(SetTransport setTransport, Uri uri, FailoverTransport transport)
 {
     _uri          = uri;
     _setTransport = setTransport;
     _transport    = transport;
 }
コード例 #7
0
ファイル: TransportFactory.cs プロジェクト: Redi0/meijing-ui
		public static ITransport AsyncCompositeConnect(Uri location, SetTransport setTransport)
		{
			ITransportFactory tf = TransportFactory.CreateTransportFactory(location);
			return tf.CompositeConnect(location, setTransport);
		}
コード例 #8
0
 public ITransport CompositeConnect(Uri location, SetTransport setTransport)
 {
     throw new NMSConnectionException("Asynchronous composite connection not supported with Failover transport.");
 }
コード例 #9
0
 public ITransport CompositeConnect(Uri location, SetTransport setTransport)
 {
     return CreateTransport(location);
 }
コード例 #10
0
        public ITransport CompositeConnect(Uri location, SetTransport setTransport)
        {
            // Extract query parameters from broker Uri
            StringDictionary map = URISupport.ParseQuery(location.Query);

            // Set transport. properties on this (the factory)
            URISupport.SetProperties(this, map, "transport.");

            // See if there is a local address and port specified
            string localAddress = null;
            int localPort = -1;

            if(!String.IsNullOrEmpty(location.AbsolutePath) && !location.AbsolutePath.Equals("/"))
            {
                int index = location.AbsolutePath.IndexOf(':');
                try
                {
                    localPort = Int16.Parse(location.AbsolutePath.Substring(index + 1));
                    localAddress = location.AbsolutePath.Substring(1, index - 1);
                    Tracer.DebugFormat("Binding Socket to {0} on port: {1}", localAddress, localPort);
                }
                catch
                {
                    Tracer.Warn("Invalid Port value on URI for local bind option, ignoring.");
                }
            }

            Tracer.Debug("Opening socket to: " + location.Host + " on port: " + location.Port);
            Socket socket = DoConnect(location.Host, location.Port, localAddress, localPort );

            #if !NETCF
            socket.ReceiveBufferSize = ReceiveBufferSize;
            socket.SendBufferSize = SendBufferSize;
            socket.ReceiveTimeout = ReceiveTimeout;
            socket.SendTimeout = SendTimeout;
            #endif

            OpenWireFormat wireformat = new OpenWireFormat();
            // Set wireformat. properties on the wireformat owned by the tcpTransport
            URISupport.SetProperties(wireformat.PreferredWireFormatInfo, map, "wireFormat.");
            ITransport transport = DoCreateTransport(location, socket, wireformat);

            wireformat.Transport = transport;

            if(UseLogging)
            {
                transport = new LoggingTransport(transport);
            }

            if(UseInactivityMonitor)
            {
               transport = new InactivityMonitor(transport);
            }

            transport = new WireFormatNegotiator(transport, wireformat);
            if(setTransport != null)
            {
                setTransport(transport, location);
            }

            return transport;
        }
コード例 #11
0
        public ITransport CompositeConnect(Uri location, SetTransport setTransport)
        {
            // Extract query parameters from broker Uri
            StringDictionary map = URISupport.ParseQuery(location.Query);

            // Set transport. properties on this (the factory)
            URISupport.SetProperties(this, map, "transport.");

            // See if there is a local address and port specified
            string localAddress = null;
            int    localPort    = -1;

            if (!String.IsNullOrEmpty(location.AbsolutePath) && !location.AbsolutePath.Equals("/"))
            {
                int index = location.AbsolutePath.IndexOf(':');
                try
                {
                    localPort    = Int16.Parse(location.AbsolutePath.Substring(index + 1));
                    localAddress = location.AbsolutePath.Substring(1, index - 1);
                    Tracer.DebugFormat("Binding Socket to {0} on port: {1}", localAddress, localPort);
                }
                catch
                {
                    Tracer.Warn("Invalid Port value on URI for local bind option, ignoring.");
                }
            }

            Tracer.Debug("Opening socket to: " + location.Host + " on port: " + location.Port);
            Socket socket = DoConnect(location.Host, location.Port, localAddress, localPort);

#if !NETCF
            socket.ReceiveBufferSize = ReceiveBufferSize;
            socket.SendBufferSize    = SendBufferSize;
            socket.ReceiveTimeout    = ReceiveTimeout;
            socket.SendTimeout       = SendTimeout;
#endif

            OpenWireFormat wireformat = new OpenWireFormat();
            // Set wireformat. properties on the wireformat owned by the tcpTransport
            URISupport.SetProperties(wireformat.PreferredWireFormatInfo, map, "wireFormat.");
            ITransport transport = DoCreateTransport(location, socket, wireformat);

            wireformat.Transport = transport;

            if (UseLogging)
            {
                transport = new LoggingTransport(transport);
            }

            if (UseInactivityMonitor)
            {
                transport = new InactivityMonitor(transport);
            }

            transport = new WireFormatNegotiator(transport, wireformat);
            if (setTransport != null)
            {
                setTransport(transport, location);
            }

            return(transport);
        }