TWebSocketMiddleware Class
Middleware that enables WebSocket support in the server modules it is added to.
Remarks
For every incoming request that is a valid WebSocket handshake, the middleware makes an IWebSocketUpgrader available in the request context, which the module can retrieve using Context.GetItem<IWebSocketUpgrader> and use to upgrade the connection to a WebSocket. Requests that are not WebSocket handshakes are forwarded unchanged. If AllowedOrigins is not empty and the request Origin header does not match it, the request is rejected with a 403 status code.
Syntax
Unit: Sparkle.Middleware.WebSocket
TWebSocketMiddleware = class(THttpServerMiddleware, IWebSocketMiddleware);
Constructors
| Name | Description |
|---|---|
| Create | Creates a new WebSocket middleware with an empty AllowedOrigins list. |
Methods
| Name | Description |
|---|---|
| ProcessRequest | Processes the request, upgrading it to a WebSocket connection when it is a valid WebSocket handshake from an allowed origin. |
Properties
| Name | Description |
|---|---|
| AllowedOrigins | The list of request origins allowed to open a WebSocket connection. |