Esempio n. 1
0
        public WebSocket(SessionThread sessionThread, InternalConnectionOptions options, string serverAddress, StreamListener streamListener, ConnectionListener connListener)
        {
            this.sessionThread = sessionThread;
            this.options       = options;
            if (TransportFactory <WebSocketProvider> .DefaultWebSocketFactory == null)
            {
                /* Note:
                 * this is a temporary hack. If the WebSocket support is not available, the transport uses a void implementation
                 * which just ignores the requests.
                 * The goal is to emulate the behavior of the old (non TLCP) Android compact client.
                 * That client doesn't support WebSocket, so when a user forces WebSocket transport
                 * the client simply ignores the requests.
                 * In the future we must address this question and work out a more user-friendly API behavior.
                 */
                this.wsClient = new DummyWebSocketClient();
            }
            else
            {
                this.wsClient = TransportFactory <WebSocketProvider> .DefaultWebSocketFactory.getInstance(sessionThread);
            }

            this.sessionListener = new MySessionRequestListener(sessionThread, streamListener, connListener);
            open(serverAddress, streamListener, connListener);

            if (log.IsDebugEnabled)
            {
                log.Debug("WebSocket transport - : " + sessionListener.state);
            }
        }
        public RequestTutor(long currentTimeout, SessionThread thread, InternalConnectionOptions connectionOptions, bool fixedTO)
        {
            try
            {
                this.sessionThread = thread;

                this.connectionOptions = connectionOptions;

                this.session = sessionThread.SessionManager.Session;

                this.serverSession = sessionThread.SessionManager.ServerSession;

                if (fixedTO)
                {
                    this.timeoutMs = this.FixedTimeout;
                }
                else
                {
                    this.timeoutMs = currentTimeout > 0 ? currentTimeout * 2 : MIN_TIMEOUT;
                }
            }
            catch (Exception e)
            {
                log.Warn("warn - " + e.Message);
                if (log.IsDebugEnabled)
                {
                    log.Debug(e.StackTrace);
                }
            }
        }
 internal HttpRequestManager(SessionThread thread, Transport transport, InternalConnectionOptions options) : this(thread, null, transport, options, null)
 {
     if (!InstanceFieldsInitialized)
     {
         InitializeInstanceFields();
         InstanceFieldsInitialized = true;
     }
 }
Esempio n. 4
0
        public LightstreamerEngine(InternalConnectionOptions options, SessionThread sessionThread, EventsThread eventsThread, ClientListener listener, SessionManager manager)
        {
            this.connectionOptions = options;
            this.sessionThread     = sessionThread;
            this.clientListener    = listener;
            this.eventsThread      = eventsThread;

            this.sessionManager      = manager;
            manager.SessionsListener = new SessionsListenerImpl(this);
        }
 public ReverseHeartbeatTimer(SessionThread sessionThread, InternalConnectionOptions options)
 {
     // // Debug.Assert(Assertions.SessionThread);
     this.sessionThread = sessionThread;
     this.options       = options;
     this.maxIntervalMs = options.ReverseHeartbeatInterval;
     if (log.IsDebugEnabled)
     {
         log.Debug("rhb max interval " + maxIntervalMs);
     }
     CurrentInterval = maxIntervalMs;
 }
 internal HttpRequestManager(SessionThread thread, Protocol protocol, Transport transport, InternalConnectionOptions options, FatalErrorListener errListener)
 {
     if (!InstanceFieldsInitialized)
     {
         InitializeInstanceFields();
         InstanceFieldsInitialized = true;
     }
     this.sessionThread = thread;
     this.transport     = transport;
     this.protocol      = protocol;
     this.options       = options;
     this.errorListener = errListener;
 }
        internal SubscriptionManager(SessionThread sessionThread, SessionManager manager, InternalConnectionOptions options)
        {
            if (!InstanceFieldsInitialized)
            {
                InitializeInstanceFields();
                InstanceFieldsInitialized = true;
            }
            this.sessionThread = sessionThread;
            this.options       = options;
            this.manager       = manager;

            manager.SubscriptionsListener = this.eventsListener;
        }
 private void InitializeInstanceFields()
 {
     dispatcher                = new EventDispatcher <ClientListener>(eventsThread);
     internalListener          = new InternalListener(this);
     internalConnectionDetails = new InternalConnectionDetails(dispatcher);
     internalConnectionOptions = new InternalConnectionOptions(dispatcher, internalListener);
     manager       = new SessionManager(internalConnectionOptions, internalConnectionDetails, sessionThread);
     engine        = new LightstreamerEngine(internalConnectionOptions, sessionThread, eventsThread, internalListener, manager);
     messages      = new MessageManager(eventsThread, sessionThread, manager, internalConnectionOptions);
     subscriptions = new SubscriptionManager(sessionThread, manager, internalConnectionOptions);
     // mpnManager = new MpnManager(manager, this, sessionThread);
     connectionOptions = new ConnectionOptions(internalConnectionOptions);
     connectionDetails = new ConnectionDetails(internalConnectionDetails);
 }
        internal MessageManager(EventsThread eventsThread, SessionThread sessionThread, SessionManager manager, InternalConnectionOptions options)
        {
            if (!InstanceFieldsInitialized)
            {
                InitializeInstanceFields();
                InstanceFieldsInitialized = true;
            }
            this.sessionThread = sessionThread;
            this.manager       = manager;
            this.options       = options;

            this.dispatcher = new EventDispatcher <ClientMessageListener>(eventsThread);

            manager.MessagesListener = this.eventsListener;
        }
 public SubscriptionsTutor(SubscriptionManager outerInstance, long currentTimeout, SessionThread thread, InternalConnectionOptions connectionOptions) : base(currentTimeout, thread, connectionOptions, outerInstance.fixedTimeout > 0)
 {
     this.outerInstance = outerInstance;
 }
        public BindSessionRequest(string targetServer, string session, bool polling, string cause, InternalConnectionOptions options, long delay, bool addContentLength, long maxReverseHeartbeatIntervalMs) : base(polling, delay)
        {
            this.Server = targetServer;

            Session = session;
            // the session ID can still be omitted from the request, depending on the transport

            if (polling)
            {
                this.addParameter("LS_polling", "true");
                this.addParameter("LS_polling_millis", options.PollingInterval + delay);
                this.addParameter("LS_idle_millis", options.IdleTimeout);
            }
            else
            {
                if (options.KeepaliveInterval > 0)
                {
                    this.addParameter("LS_keepalive_millis", options.KeepaliveInterval);
                }

                if (maxReverseHeartbeatIntervalMs > 0)
                {
                    this.addParameter("LS_inactivity_millis", maxReverseHeartbeatIntervalMs);
                }

                if (addContentLength)
                {
                    this.addParameter("LS_content_length", options.ContentLength);
                }
            }

            if (!string.ReferenceEquals(cause, null))
            {
                this.addParameter("LS_cause", cause);
            }
        }
 public TextProtocolHttp(int objectId, SessionThread thread, InternalConnectionOptions options, Http httpTransport) : base(objectId, thread, options, httpTransport)
 {
 }
Esempio n. 13
0
 public TextProtocolWS(int objectId, SessionThread thread, InternalConnectionOptions options, InternalConnectionDetails details, Http httpTransport) : base(objectId, thread, options, httpTransport)
 {
     wsRequestManager = new WebSocketRequestManager(thread, this, options);
 }
 public VoidTutor(SessionThread thread, InternalConnectionOptions connectionOptions) : base(thread, connectionOptions)
 {
 }
Esempio n. 15
0
 internal ConnectionOptions(InternalConnectionOptions @internal)
 {
     this.@internal = @internal;
 }
 public RequestTutor(SessionThread thread, InternalConnectionOptions connectionOptions) : this(0, thread, connectionOptions, false)
 {
 }
            public ChangeSubscriptionTutor(SubscriptionManager outerInstance, long currentTimeout, SessionThread thread, InternalConnectionOptions connectionOptions, ChangeSubscriptionRequest request) : base(outerInstance, currentTimeout, thread, connectionOptions)
            {
                this.outerInstance = outerInstance;

                this.request = request;
            }
 public WebSocketRequestManager(SessionThread sessionThread, Protocol protocol, InternalConnectionOptions options)
 {
     this.options       = options;
     this.sessionThread = sessionThread;
     this.protocol      = protocol;
 }