Script event of MyChat Server: OnClientPluginSendRawData
The event for receiving a particular command to send a RAW data from one MyChat Client plugin to another. Commands for sending a RAW data are needed for client plugins to exchange data of any format between each other within a network by using the default protocol of MyChat.
Event template
function OnClientPluginSendRawData(iCID, iUINFrom, iUINTo: integer; sPluginNameFrom, sPluginNameTo, sData: string): boolean;
begin
// your own code
result := true;
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; |
iUINFrom |
integer |
unique identifier of the command sender (number > 0); |
iUINTo |
integer |
unique identifier of the command recipient (number > 0); |
sPluginNameFrom |
string |
name of the command plugin-sender. The letter case matters; |
sPluginNameTo |
string |
name of the command plugin-recipient. The letter case matters; |
sData |
string |
text data of a RAW message. |
Return value
True, if you skip this message, False if you block it.
Example
Task: you need to allow heads of departments to launch UltraVNC plugin for remote viewing within the network of user computer screens but only in own department. You can't use the mouse and keyboard. The script must send corresponding notifications about the impossibility to start the session of remote screen viewing if a user is not allowed to do so.
These rules must not apply to network administrators.
const
sAdmGroup = 'Administrators';
sErrMsg1 = 'You do not have access to this user';
sErrMsg2 = 'You can only view this user's screen';
function OnClientPluginSendRawData(iCID, iUINFrom, iUINTo: integer; sPluginNameFrom, sPluginNameTo, sData: string): boolean;
var
bFlag: boolean;
iDeptID1, iDeptID2: integer;
sMsg: string;
begin
bFlag := true;
// if a user is opening the VNCClient plugin
if (sPluginNameFrom = 'VNCClient') and (sPluginNameTo = 'VNCServer') then
// if this is not a user from the rights group "Administrators"
if mGetRoleNameByID(mGetUserRoleID(iUINFrom)) <> sAdmGroup then begin
// if a user is going to view the screen of the remote computer only
if sData = 'VNCGETLOCALIPS-VIEW' then begin
bFlag := false;
iDeptID1 := mGetUserDepartmentID(iUINFrom);
iDeptID2 := mGetUserDepartmentID(iUINTo);
// if users are from the same department
// ? iUINFrom - the head of this department
if iDeptID1 = iDeptID2 then bFlag := mIsUserTeamLead(iUINFrom);
if not bFlag then sMsg := sErrMsg1;
end else
// if a user is trying to take control over the mouse and keyboard
// then forbid him to open the VNC
if sData = 'VNCGETLOCALIPS-CONTROL' then begin
sMsg := sErrMsg2;
bFlag := false;
end;
if not bFlag then
// send a message about impossibility to a user
// open the session of remote administration
mSendCustomMsgToClientConsoleByCID(iCID,
sMsg +
' (' + mGetUserAttribute(iUINTo, 'DisplayName') + ')',
'Error', true, true, 77);
end;
result := bFlag;
end;
begin
end.