コード例 #1
0
        public override void StartConnect()
        {
            if (this.State != TransportStates.Initial)
            {
                return;
            }

            HTTPManager.Logger.Information("LongPollingTransport", "StartConnect");

            this.State = TransportStates.Connecting;

            // https://github.com/aspnet/SignalR/blob/dev/specs/HubProtocol.md#overview
            // When our connection is open, send the 'negotiation' message to the server.

            var request = new HTTPRequest(BuildUri(this.connection.Uri), HTTPMethods.Post, OnHandshakeRequestFinished);

            this.stream.Write(JsonProtocol.WithSeparator(string.Format("{{\"protocol\":\"{0}\", \"version\": 1}}", this.connection.Protocol.Encoder.Name)));

            request.UploadStream = this.stream;

            if (this.connection.AuthenticationProvider != null)
            {
                this.connection.AuthenticationProvider.PrepareRequest(request);
            }

            request.Send();
        }
コード例 #2
0
        // The websocket connection is open
        private void OnOpen(WebSocket.WebSocket webSocket)
        {
            HTTPManager.Logger.Verbose("WebSocketTransport", "OnOpen");

            // https://github.com/aspnet/SignalR/blob/dev/specs/HubProtocol.md#overview
            // When our websocket connection is open, send the 'negotiation' message to the server.
            (this as ITransport).Send(JsonProtocol.WithSeparator(string.Format("{{\"protocol\":\"{0}\", \"version\": 1}}", this.connection.Protocol.Name)));
        }
コード例 #3
0
        private void OnOpen(WebSocket.WebSocket webSocket)
        {
            // When our websocket connection is open, send the 'negotiation' message to the server.
            // It's not a real negotiation step, as we don't expect an answer to this.

            string json = this.connection.ComposeNegotiationMessage();

            byte[] buffer = JsonProtocol.WithSeparator(json);

            Send(buffer);
        }
コード例 #4
0
        // The websocket connection is open
        private void OnOpen(WebSocket.WebSocket webSocket)
        {
            HTTPManager.Logger.Verbose("WebSocketTransport", "OnOpen");

            // https://github.com/aspnet/SignalR/blob/dev/specs/HubProtocol.md#overview
            // When our websocket connection is open, send the 'negotiation' message to the server.

            string json = string.Format("{{'protocol':'{0}', 'version': 1}}", this.connection.Protocol.Encoder.Name);

            byte[] buffer = JsonProtocol.WithSeparator(json);

            (this as ITransport).Send(buffer);
        }