Script event of MyChat Server: OnClientDisconnect
The event that occurs at the moment of user disconnection from the server. It does not matter if it is a regular or emergency the very fact of the disconnection is tracked.
Event template
procedure OnClientDisconnect(iCID, iUIN: integer; sIP, sClientType: string);
begin
// your own code
end;
begin
end.
You can put your code instead of the comment.
Description of parameters
Parameter |
Type |
Value |
iCID |
integer |
Connection ID of the client, unique session identifier in the online structure of network connections to the server; |
iUIN |
integer |
user's unique identifier. If a user is not authorized for some reason then it can be equal to -1; |
sIP |
string |
user's IP address that just connected; |
sClientType |
string |
client application type of a user. |
Example
The script tracks which user is disconnected from the server and if he was authorized (UIN <> -1) and entered the chat from a browser (application type = 'web') then this event is recorded to a text file with date/time, user UIN and IP address.
const
LOG_FILE = 'c:\temp\webclients.log';
procedure OnClientDisconnect(iCID, iUIN: integer; sIP, sClientType: string);
var
s: string;
begin
if (sClientType = 'web') and (iUIN <> -1) then begin
s := 'UIN: ' + inttostr(iUIN) + ', IP: ' + sIP;
Protocol(s, LOG_FILE, true);
end;
end;
begin
end.