/// <summary> /// Create http2 session. Close if previously opened. /// </summary> /// <param name="uri">The URI</param> /// <param name="option">Options for session</param> /// <returns>The return code.</returns> private static int CreateSession(Uri uri, ProtocolOptions option) { int res = 0; CloseSession(); session = new ProtocolSession(uri, false, option); // URI can still be invalid, missing protocol prefix for example try { session.Open(); session.OnOpen += OnSessionOpened; session.OnClose += OnSessionClosed; session.OnError += OnSessionError; session.OnStreamOpened += OnStreamOpened; session.OnStreamClosed += OnStreamClosed; // wait until session changes its state // for high latency connections we cannot just start using this session sessionMonitorEvent.Reset(); } catch (Exception e) { Http2Logger.LogError("Unable to open session for " + uri + ". " + e.Message); res = 1; } return res; }
private void CreateSession(VirtualSocket socket) { try { Console.WriteLine("New connection"); var options = new ProtocolOptions(); ProtocolSession session = new ProtocolSession(socket, options); session.OnStreamOpened += session_OnStreamOpened; session.OnError += session_OnError; session.Open(); } catch (Exception e) { Console.WriteLine(e.Message); } }