internal virtual void ResyncSession() { Stream stream = null; StreamReader answer = null; PushServerProxyInfo info = null; IOException exception2; sessionLogger.Info("Rebinding session " + this.serverInfo.sessionId); try { stream = this.serverTranslator.CallResync(this.serverInfo, null); answer = new StreamReader(stream, Encoding.Default); this.serverTranslator.CheckAnswer(answer); info = this.serverTranslator.ReadSessionId(answer); } catch (PushUserException exception) { sessionLogger.Info("Refused resync request" + this.serverInfo.sessionId); protLogger.Debug("Refused resync request", exception); throw new PushServerException(7); } catch (IOException exception4) { exception2 = exception4; sessionLogger.Info("Unsuccessful rebinding of session " + this.serverInfo.sessionId); sessionLogger.Debug("Unsuccessful rebinding of session " + this.serverInfo.sessionId, exception2); throw new PushConnException(exception2); } catch (WebException exception3) { sessionLogger.Info("Unsuccessful rebinding of session " + this.serverInfo.sessionId); sessionLogger.Debug("Unsuccessful rebinding of session " + this.serverInfo.sessionId, exception3); throw new PushConnException(exception3); } bool flag = false; lock (this) { if (!this.closed) { this.Dispose(); this.pushLowLevelStream = stream; this.pushStream = answer; this.serverInfo = info; this.closed = false; } else { flag = true; } } if (!flag) { sessionLogger.Info("Rebind successful on session " + this.serverInfo.sessionId); } else { sessionLogger.Info("Rebind successful but no longer requested"); try { streamLogger.Debug("Closing connection"); answer.Close(); } catch (IOException exception6) { exception2 = exception6; streamLogger.Debug("Error closing the connection", exception2); } try { stream.Close(); } catch (IOException exception7) { exception2 = exception7; streamLogger.Debug("Error closing the connection", exception2); } throw new PhaseException(); } }
internal virtual void StartSession(Stream stream) { StreamReader answer = null; PushServerProxyInfo info = null; sessionLogger.Info("Starting new session"); try { answer = new StreamReader(stream, Encoding.Default); this.serverTranslator.CheckAnswer(answer); info = this.serverTranslator.ReadSessionId(answer); } catch (IOException exception) { sessionLogger.Info("Unsuccessful start of new session"); sessionLogger.Debug("Unsuccessful start of new session", exception); throw new PushConnException(exception); } catch (WebException exception2) { sessionLogger.Info("Unsuccessful start of new session"); sessionLogger.Debug("Unsuccessful start of new session", exception2); throw new PushConnException(exception2); } bool flag = false; lock (this) { if (!this.closed) { flag = true; } else { this.pushLowLevelStream = stream; this.pushStream = answer; this.serverInfo = info; this.closed = false; } } if (!flag) { sessionLogger.Info("Started session " + this.serverInfo.sessionId); } else { IOException exception3; sessionLogger.Info("Session started but no longer requested"); try { streamLogger.Debug("Closing connection"); answer.Close(); } catch (IOException exception5) { exception3 = exception5; streamLogger.Debug("Error closing the connection", exception3); } try { stream.Close(); } catch (IOException exception6) { exception3 = exception6; streamLogger.Debug("Error closing the connection", exception3); } throw new PhaseException(); } }
internal virtual void StartSession(Stream stream) { StreamReader answer = null; PushServerProxyInfo info = null; sessionLogger.Info("Starting new session"); try { answer = new StreamReader(stream, Encoding.UTF8); this.serverTranslator.CheckAnswer(answer); info = this.serverTranslator.ReadSessionId(answer); } catch (PushEndException) { throw new PushServerException(7); } catch (IOException e) { sessionLogger.Info("Unsuccessful start of new session"); sessionLogger.Debug("Unsuccessful start of new session", e); throw new PushConnException(e); } catch (WebException e) { sessionLogger.Info("Unsuccessful start of new session"); sessionLogger.Debug("Unsuccessful start of new session", e); throw new PushConnException(e); } bool late = false; lock (this) { if (!this.closed) { late = true; } else { this.pushLowLevelStream = stream; this.pushStream = answer; this.streamCompleted = false; this.serverInfo = info; this.closed = false; } } if (!late) { sessionLogger.Info("Started session " + this.serverInfo.sessionId); } else { sessionLogger.Info("Session started but no longer requested"); this.DisposeStreams(stream, answer, info); throw new PhaseException(); } }
internal virtual void ResyncSession() { Stream stream = null; StreamReader answer = null; PushServerProxyInfo info = null; sessionLogger.Info("Rebinding session " + this.serverInfo.sessionId); this.Check(); try { stream = this.serverTranslator.CallResync(this.serverInfo, null); answer = new StreamReader(stream, Encoding.UTF8); this.serverTranslator.CheckAnswer(answer); info = this.serverTranslator.ReadSessionId(answer); } catch (PushUserException e1) { sessionLogger.Info("Refused resync request " + this.serverInfo.sessionId); protLogger.Debug("Refused resync request", e1); throw new PushServerException(9); } catch (IOException e) { sessionLogger.Info("Unsuccessful rebinding of session " + this.serverInfo.sessionId); sessionLogger.Debug("Unsuccessful rebinding of session " + this.serverInfo.sessionId, e); throw new PushConnException(e); } catch (WebException e) { sessionLogger.Info("Unsuccessful rebinding of session " + this.serverInfo.sessionId); sessionLogger.Debug("Unsuccessful rebinding of session " + this.serverInfo.sessionId, e); throw new PushConnException(e); } bool late = false; lock (this) { if (!this.closed) { this.Dispose(false); this.pushLowLevelStream = stream; this.pushStream = answer; this.streamCompleted = false; this.serverInfo = info; } else { late = true; } } if (!late) { sessionLogger.Info("Rebind successful on session " + this.serverInfo.sessionId); } else { sessionLogger.Info("Rebind successful but no longer requested"); this.DisposeStreams(stream, answer, null); throw new PhaseException(); } }
internal virtual void DisposeStreams(Stream closingLowLevelStream, StreamReader closingStream, PushServerProxyInfo closingInfo) { new AnonymousClassThread1(closingLowLevelStream, closingStream, this).Start(true); if (closingInfo != null) { new AnonymousClassThread2(closingInfo, this).Start(true); } }