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); } } }
public static Session GetSession(string sessionKey) { if (!isStarted) { isStarted = true; SessionThread obj = new SessionThread(sessionList); Thread thr = new Thread(new ThreadStart(obj.LimparSessoesVencidas)); thr.Start(); } for (int i = 0; i < sessionList.Count; i++) { if (sessionList[i].SessionKey == sessionKey) { sessionList[i].LastUpdate = DateTime.Now; return(sessionList[i]); } } Session newSession = new Session(sessionKey); newSession.LastUpdate = DateTime.Now; sessionList.Add(newSession); return(newSession); }
public NettyHttpProvider(SessionThread thread) { this.sessionThread = thread; this.httpPoolManager = SingletonFactory.instance.HttpPool; this.objectId = Interlocked.Increment(ref objectIdCounter); }
internal HttpRequestManager(SessionThread thread, Transport transport, InternalConnectionOptions options) : this(thread, null, transport, options, null) { if (!InstanceFieldsInitialized) { InitializeInstanceFields(); InstanceFieldsInitialized = true; } }
//Prepare a new session public void PrepareSession(Session session = null) { SessionThread?.Join(); if (session == null) { CurrentSession = new Session { Username = SettingsManager.Instance.Settings["api"]["user"] }; } else { CurrentSession = session; } if (CurrentSession.ReadOnly) { OsuUser currentUserData = null; try { currentUserData = OsuApi.GetUser(CurrentSession.Username, (OsuMode)Enum.Parse(typeof(OsuMode), SettingsManager.Instance.Settings["api"]["gamemode"])); } catch (Exception) { BrowserViewModel.Instance.SendNotification(NotificationType.Danger, StringStorage.Get("Message.UserDataError")); return; } BrowserViewModel.Instance.ApplySession(CurrentSession); BrowserViewModel.Instance.ApplyUser(currentUserData); StopProgressHandler(); BrowserViewModel.Instance.AttachedJavascriptWrapper.Hide("#sessionProgressTime"); BrowserViewModel.Instance.AttachedJavascriptWrapper.Show("#sessionProgressReadonly"); string startDate = DateTimeOffset.FromUnixTimeSeconds(CurrentSession.SessionDate).ToString("MMMM dd yyyy HH:mm:ss"); string endDate = DateTimeOffset.FromUnixTimeSeconds(CurrentSession.SessionEndDate).ToString("MMMM dd yyyy HH:mm:ss"); BrowserViewModel.Instance.AttachedJavascriptWrapper.SetHtml("#sessionProgressReadonlyText", startDate + " to " + endDate); } else { SessionThread = new ExtendedThread(() => OnUpdate(), Convert.ToInt32(SettingsManager.Instance.Settings["api"]["updateRate"])); lastIteration = DateTimeOffset.Now.ToUnixTimeSeconds(); nextIteration = DateTimeOffset.Now.ToUnixTimeSeconds() + SessionThread.SleepTime; StartProgressHandler(); SessionThread.Start(); BrowserViewModel.Instance.AttachedJavascriptWrapper.Hide("#sessionProgressReadonly"); if (SettingsManager.Instance.Settings["display"]["showTimer"] == "true") { BrowserViewModel.Instance.AttachedJavascriptWrapper.Show("#sessionProgressTime"); } } }
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; }
private void ListenForMessages() { if (listeningThread == null) { IThreadRunnable messageReader = new SessionThread(this); listeningThread = new SupportClass.ThreadClass(new System.Threading.ThreadStart(messageReader.Run), "FAST Session Message Reader"); } if (listeningThread.IsAlive) { return; } listeningThread.Start(); }
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; }
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 void Stop() { StopProgressHandler(); SessionThread?.Join(); if (File.Exists("Data/stored_sessions.json")) { File.Delete("Data/stored_sessions.json"); } using (StreamWriter sw = new StreamWriter("Data/stored_sessions.json")) { string data = JsonConvert.SerializeObject(SessionFiles); sw.Write(data); sw.Close(); } }
public ChangeSubscriptionTutor(SubscriptionManager outerInstance, long currentTimeout, SessionThread thread, InternalConnectionOptions connectionOptions, ChangeSubscriptionRequest request) : base(outerInstance, currentTimeout, thread, connectionOptions) { this.outerInstance = outerInstance; this.request = request; }
public SubscribeTutor(SubscriptionManager outerInstance, int subscriptionId, int subscriptionPhase, SessionThread thread, long timeoutMs) : base(outerInstance, timeoutMs, thread, outerInstance.options) { this.outerInstance = outerInstance; this.subscriptionId = subscriptionId; this.subscriptionPhase = subscriptionPhase; }
public SubscriptionsTutor(SubscriptionManager outerInstance, long currentTimeout, SessionThread thread, InternalConnectionOptions connectionOptions) : base(currentTimeout, thread, connectionOptions, outerInstance.fixedTimeout > 0) { this.outerInstance = outerInstance; }
public VoidTutor(SessionThread thread, InternalConnectionOptions connectionOptions) : base(thread, connectionOptions) { }
public RequestTutor(SessionThread thread, InternalConnectionOptions connectionOptions) : this(0, thread, connectionOptions, false) { }
public Http(SessionThread thread, HttpProvider httpProvider) { this.sessionThread = thread; this.httpProvider = httpProvider; this.sessionThread.registerShutdownHook(httpProvider.ShutdownHook); }
private void ListenForMessages() { if (listeningThread == null) { IThreadRunnable messageReader = new SessionThread(this); listeningThread = new SupportClass.ThreadClass(new System.Threading.ThreadStart(messageReader.Run), "FAST Session Message Reader"); } if (listeningThread.IsAlive) return ; listeningThread.Start(); }
public MyHttpListener(RequestListener listener, LightstreamerRequest request, SessionThread sessionThread) { this.listener = listener; this.request = request; this.sessionThread = sessionThread; }
internal MySessionRequestListener(SessionThread sessionThread, StreamListener streamListener, ConnectionListener connListener) { this.sessionThread = sessionThread; this.streamListener = streamListener; this.connectionListener = connListener; }
/* * Instance methods of a generic transport factory. */ /// <summary> /// Returns a new instance of a transport. /// </summary> public abstract T getInstance(SessionThread thread);
// TEST ONLY public NettyHttpProvider(SessionThread thread, HttpPoolManager channelPool) { this.sessionThread = thread; this.httpPoolManager = channelPool; this.objectId = Interlocked.Increment(ref objectIdCounter); }
public TextProtocolWS(int objectId, SessionThread thread, InternalConnectionOptions options, InternalConnectionDetails details, Http httpTransport) : base(objectId, thread, options, httpTransport) { wsRequestManager = new WebSocketRequestManager(thread, this, options); }
public TextProtocolHttp(int objectId, SessionThread thread, InternalConnectionOptions options, Http httpTransport) : base(objectId, thread, options, httpTransport) { }
public WebSocketRequestManager(SessionThread sessionThread, Protocol protocol, InternalConnectionOptions options) { this.options = options; this.sessionThread = sessionThread; this.protocol = protocol; }