public virtual RequestHandle bindSession(BindSessionRequest request, StreamListener reqListener, long tcpConnectTimeout, long tcpReadTimeout, ListenableFuture requestFuture) { RequestHandle handle = transport.sendRequest(protocol, request, reqListener, options.HttpExtraHeadersOnSessionCreationOnly ? null : options.HttpExtraHeaders, options.Proxy, tcpConnectTimeout, tcpReadTimeout); requestFuture.fulfill(); return(handle); }
/// <summary> /// {@inheritDoc} /// If the socket is not open, calls <seealso cref="#openSocket(String, StreamListener)"/>. /// </summary> public virtual RequestHandle bindSession(BindSessionRequest request, StreamListener reqListener, long tcpConnectTimeout, long tcpReadTimeout, ListenableFuture bindFuture) { if (wsTransport == null) { // no transport: this case can happen when transport is polling bindRequest = new PendingBind(request, reqListener, bindFuture); openWS(protocol, request.TargetServer, reqListener); } else { // there is a transport, so openSocket was already called: the state is CONNECTED or CONNECTING WebSocket.InternalState state = wsTransport.State; switch (state) { case WebSocket.InternalState.CONNECTED: sendBindRequest(request, reqListener, bindFuture); break; case WebSocket.InternalState.CONNECTING: // buffer the request, which will be flushed when the client state is CONNECTED Debug.Assert(bindRequest == null); bindRequest = new PendingBind(request, reqListener, bindFuture); break; case WebSocket.InternalState.BROKEN: // discard bind request: must be sent in HTTP break; default: // Debug.Assert(false, state); sessionLog.Warn("Unexpected bind request in state " + state); break; } } // this request handle close the stream connection return(new RequestHandleAnonymousInnerClass(this)); }