コード例 #1
0
        public BayeuxClient(string url, IList <ClientTransport> transports)
        {
            _handshakeListener  = new HandshakeTransportListener(this);
            _connectListener    = new ConnectTransportListener(this);
            _disconnectListener = new DisconnectTransportListener(this);
            _publishListener    = new PublishTransportListener(this);

            if (transports == null || transports.Count == 0)
            {
                throw new ArgumentException("Transport cannot be null");
            }

            foreach (var t in transports)
            {
                _transportRegistry.Add(t);
            }

            foreach (var transportName in _transportRegistry.KnownTransports)
            {
                var clientTransport = _transportRegistry.GetTransport(transportName);
                if (!(clientTransport is HttpClientTransport))
                {
                    continue;
                }

                var httpTransport = (HttpClientTransport)clientTransport;
                httpTransport.Url = url;
            }

            _bayeuxClientState = new DisconnectedState(this, null);
        }
コード例 #2
0
ファイル: BayeuxClient.cs プロジェクト: KhaledSMQ/spikes
        public BayeuxClient(String url, IList <ClientTransport> transports)
        {
            //logger = Log.getLogger(GetType().FullName + "@" + this.GetHashCode());
            //Console.WriteLine(GetType().FullName + "@" + this.GetHashCode());

            handshakeListener  = new HandshakeTransportListener(this);
            connectListener    = new ConnectTransportListener(this);
            disconnectListener = new DisconnectTransportListener(this);
            publishListener    = new PublishTransportListener(this);

            if (transports == null || transports.Count == 0)
            {
                throw new ArgumentException("Transport cannot be null");
            }

            foreach (ClientTransport t in transports)
            {
                transportRegistry.Add(t);
            }

            foreach (String transportName in transportRegistry.KnownTransports)
            {
                ClientTransport clientTransport = transportRegistry.getTransport(transportName);
                if (clientTransport is HttpClientTransport)
                {
                    HttpClientTransport httpTransport = (HttpClientTransport)clientTransport;
                    httpTransport.setURL(url);
                    httpTransport.setCookieCollection(cookieCollection);
                }
            }

            bayeuxClientState = new DisconnectedState(this, null);
        }