TsgcWebSocketHTTPServer › Events

TsgcWebSocketHTTPServer Events

Events you can handle, grouped by purpose, followed by the full alphabetical list.

Lifecycle

NameDescription
OnStartupFires after the server has started and is ready to accept connections.
OnShutdownFires after the server has stopped and no more connections are accepted.
OnTCPConnectFires after a client connects at TCP level and before the WebSocket handshake, so the connection can be accepted or rejected.
OnConnectFires every time a WebSocket connection is established with a client.
OnDisconnectFires every time a WebSocket connection with a client is dropped.
OnHandshakeFires after the handshake is evaluated on the server side and before the response is sent.
OnErrorFires whenever a WebSocket protocol error occurs, such as a mal-formed handshake.
OnExceptionFires whenever an unhandled exception is raised while processing a client connection.
OnUnknownProtocolFires when the first message does not match a known protocol so the connection can be accepted or rejected.
OnUnknownAuthenticationFires when authentication is enabled and the authentication method is not recognized by the server.

Data

NameDescription
OnMessageFires every time a client sends a text message and it is received by the server.
OnBinaryFires every time a client sends a binary message and it is received by the server.
OnFragmentedFires when a fragment of a message is received (only when Options.FragmentedMessages is frgAll or frgOnlyFragmented).

HTTP

NameDescription
OnBeforeCommandFires before OnCommandGet or OnCommandOther so the request can be screened, authorized, or short-circuited with a 401 response.
OnCommandGetFires when the HTTP server receives a GET, POST, or HEAD request so the application can build the response.
OnCommandOtherFires when the HTTP server receives a method other than GET, POST or HEAD (PUT, DELETE, OPTIONS, PATCH...).
OnBeforeForwardHTTPFires before an HTTP request is dispatched so it can be forwarded (reverse-proxied) to another HTTP server.
OnAfterForwardHTTPFires after an HTTP request has been forwarded so the application can inspect the result or an error returned by the upstream server.
OnHTTP2BeforeAsyncRequestFires before an HTTP/2 request is queued so the application can choose whether it runs in the pool of threads or in the connection thread.

Sessions

NameDescription
OnCreateSessionFires when the HTTP server needs to create a new session so the application can supply a custom TIdHTTPSession instance.
OnSessionStartFires when an HTTP session is started and added to the SessionList.
OnSessionEndFires when an HTTP session is closed, either explicitly or after SessionTimeout expires.
OnInvalidSessionFires when an HTTP request presents an unknown or expired session ID so the application can decide how to react.

HTTP Upload

NameDescription
OnHTTPUploadBeforeSaveFileFires before a file extracted from a multipart/form-data upload is saved to disk so the name and path can be customized.
OnHTTPUploadAfterSaveFileFires after a file extracted from a multipart/form-data upload has been saved to disk.
OnHTTPUploadReadInputFires when the multipart/form-data decoder reads a non-file input field so its value can be captured.
OnHTTPUploadBeforeCreatePostStreamFires after the request headers have been read and before the POST stream is created so the upload can be accepted or rejected.

Reliability

NameDescription
OnBeforeHeartBeatFires before each HeartBeat ping so the application can implement a custom keep-alive.
OnLoadBalancerConnectFires when the server connects to the Load Balancer Server.
OnLoadBalancerDisconnectFires when the server disconnects from the Load Balancer Server.
OnLoadBalancerErrorFires when an error occurs communicating with the Load Balancer Server.

Security

NameDescription
OnAuthenticationFires when authentication is enabled so the application can check user and password and accept or reject the connection.
OnSSLGetHandlerFires before the SSL handler is created so a custom server-side handler instance can be supplied.
OnSSLAfterCreateHandlerFires after the SSL handler has been created so its properties can be customized.
OnSSLALPNSelectFires during an ALPN-enabled handshake so the application can pick which protocol to negotiate.
OnSSLVerifyPeerFires when VerifyCertificate is enabled and the client presents a certificate to be accepted or rejected.

All Events (alphabetical)

NameDescription
OnAfterForwardHTTPFires after an HTTP request has been forwarded so the application can inspect the result or an error returned by the upstream server.
OnAuthenticationFires when authentication is enabled so the application can check user and password and accept or reject the connection.
OnBeforeCommandFires before OnCommandGet or OnCommandOther so the request can be screened, authorized, or short-circuited with a 401 response.
OnBeforeForwardHTTPFires before an HTTP request is dispatched so it can be forwarded (reverse-proxied) to another HTTP server.
OnBeforeHeartBeatFires before each HeartBeat ping so the application can implement a custom keep-alive.
OnBinaryFires every time a client sends a binary message and it is received by the server.
OnCommandGetFires when the HTTP server receives a GET, POST, or HEAD request so the application can build the response.
OnCommandOtherFires when the HTTP server receives a method other than GET, POST or HEAD (PUT, DELETE, OPTIONS, PATCH...).
OnConnectFires every time a WebSocket connection is established with a client.
OnCreateSessionFires when the HTTP server needs to create a new session so the application can supply a custom TIdHTTPSession instance.
OnDisconnectFires every time a WebSocket connection with a client is dropped.
OnErrorFires whenever a WebSocket protocol error occurs, such as a mal-formed handshake.
OnExceptionFires whenever an unhandled exception is raised while processing a client connection.
OnFragmentedFires when a fragment of a message is received (only when Options.FragmentedMessages is frgAll or frgOnlyFragmented).
OnHandshakeFires after the handshake is evaluated on the server side and before the response is sent.
OnHTTP2BeforeAsyncRequestFires before an HTTP/2 request is queued so the application can choose whether it runs in the pool of threads or in the connection thread.
OnHTTPUploadAfterSaveFileFires after a file extracted from a multipart/form-data upload has been saved to disk.
OnHTTPUploadBeforeCreatePostStreamFires after the request headers have been read and before the POST stream is created so the upload can be accepted or rejected.
OnHTTPUploadBeforeSaveFileFires before a file extracted from a multipart/form-data upload is saved to disk so the name and path can be customized.
OnHTTPUploadReadInputFires when the multipart/form-data decoder reads a non-file input field so its value can be captured.
OnInvalidSessionFires when an HTTP request presents an unknown or expired session ID so the application can decide how to react.
OnLoadBalancerConnectFires when the server connects to the Load Balancer Server.
OnLoadBalancerDisconnectFires when the server disconnects from the Load Balancer Server.
OnLoadBalancerErrorFires when an error occurs communicating with the Load Balancer Server.
OnMessageFires every time a client sends a text message and it is received by the server.
OnSessionEndFires when an HTTP session is closed, either explicitly or after SessionTimeout expires.
OnSessionStartFires when an HTTP session is started and added to the SessionList.
OnShutdownFires after the server has stopped and no more connections are accepted.
OnSSLAfterCreateHandlerFires after the SSL handler has been created so its properties can be customized.
OnSSLALPNSelectFires during an ALPN-enabled handshake so the application can pick which protocol to negotiate.
OnSSLGetHandlerFires before the SSL handler is created so a custom server-side handler instance can be supplied.
OnSSLVerifyPeerFires when VerifyCertificate is enabled and the client presents a certificate to be accepted or rejected.
OnStartupFires after the server has started and is ready to accept connections.
OnTCPConnectFires after a client connects at TCP level and before the WebSocket handshake, so the connection can be accepted or rejected.
OnUnknownAuthenticationFires when authentication is enabled and the authentication method is not recognized by the server.
OnUnknownProtocolFires when the first message does not match a known protocol so the connection can be accepted or rejected.