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(); }
// 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))); }
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); }
// 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); }