IPWorks WebSockets 2020 Qt Edition

Questions / Feedback?

WebSocketOpenRequest Event

Fired when a client attempts to open a WebSocket.

Syntax

class WebSocketProxyWebSocketOpenRequestEventParams {
public:
  int ConnectionId();
  const QString &RequestURI();
  const QString &HostHeader();
  const QString &OriginHeader();
  const QString &SubProtocols();
  void SetSubProtocols(const QString &qsSubProtocols);
  const QString &Extensions();
  const QString &RequestHeaders();
  int StatusCode();
  void SetStatusCode(int iStatusCode);
  const QString &ResponseHeaders();
  void SetResponseHeaders(const QString &qsResponseHeaders);
  const QString &ForwardHost();
  void SetForwardHost(const QString &qsForwardHost);
  int ForwardPort();
  void SetForwardPort(int iForwardPort);
  int EventRetVal();
  void SetEventRetVal(int iRetVal);
};
// To handle, connect one or more slots to this signal. void WebSocketOpenRequest(WebSocketProxyWebSocketOpenRequestEventParams *e);
// Or, subclass WebSocketProxy and override this emitter function. virtual int FireWebSocketOpenRequest(WebSocketProxyWebSocketOpenRequestEventParams *e) {...}

Remarks

This event fires when a client connects. It provides an opportunity to inspect the WebSocket request and either accept or reject the connection attempt.

By default, the class will accept the connection. You do not need to set anything to accept the connection. The class will return a StatusCode of 101 to the connecting client and the request will proceed as normal. To reject a connection, set StatusCode to an HTTP error code, such as 401.

ConnectionId identifies the connecting client.

RequestURI provides the URI requested by the connecting client. This may be used to implement logic to select appropriate SubProtocols or determine if the connection should be accepted based on access restrictions to the URI.

HostHeader holds the value of the Host header sent by the client.

OriginHeader holds the value of the Origin header sent by the client.

SubProtocols holds a comma separated list of subprotocols sent by the client (if any). Set SubProtocols to the selected value from the list sent by the client. The class will return this value to the client as the subprotocol the server has selected.

Extensions provides a list of extensions supported by the client.

RequestHeaders contains the HTTP headers sent in the request by the connecting client.

StatusCode determines success or failure. The value 101 (default) indicates success. This may be set to any HTTP status code. For instance a value of 401 indicates an authorization failure.

ResponseHeaders may be set to include additional headers in the response. This is typically used when rejecting a request. For instance when StatusCode is set to 401 you might set ResponseHeaders to "WWW-Authenticate: Basic realm="Secure Realm"" to request authorization from the connecting client.

ForwardHost may be set to override the value specified in DefaultForwardHost.

ForwardPort may be set to override the value specified in DefaultForwardPort.

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks WebSockets 2020 Qt Edition - Version 20.0 [Build 8155]