TsgcWebSocketServer_HTTPAPI › Events › OnAuthentication
Fires when authentication is enabled so the application can check user and password and accept or reject the connection.
public event TsgcWSAuthenticationEventHandler OnAuthentication;
// delegate void TsgcWSAuthenticationEventHandler(TsgcWSConnection Connection, string aUser, string aPassword, out bool Authenticated)
—
OnAuthentication is raised every time the server receives an authentication request from a client, provided Authentication.Enabled is True and the authentication method is one of the built-in schemes (Basic, Session, URL). The aUser and aPassword parameters carry the credentials supplied by the client; set Authenticated to True to accept the connection or to False to reject it. When the credentials are not validated here the built-in AuthUsers list is used as the fallback.
void OnAuthentication(TsgcWSConnection Connection, string aUser, string aPassword,
ref bool Authenticated)
{
if ((aUser == "user") && (aPassword == "secret"))
Authenticated = true;
else
Authenticated = false;
}