Sending a special message to MyChat Client console.

 

Syntax

function mSendCustomMsgToClientConsoleByCID(iCID: integer; sMsg, sSound: string; bFocus, bSaveToLog: boolean; iType: integer): integer;

 

Parameters and return values

Parameter

Type

Value

iCID

integer

unique identifier of client connection in server online structure;

sMsg

string

message text. You can use line breaks (CRLF);

sSound

string

type of sound message (can be specified). If you specify an empty string, then there will be no sound in MyChat Client. If all sounds are disabled in client settings, there will be no sound notification too. You can find a list of available sounds in the list of MyChat Client sounds;

bFocus

boolean

forcibly switch a client program to console for showing the message;

bSaveToLog

boolean

save the message to client protocol on a disk (not only show it in the console);

iType

integer

message type, one of the variants.

 

Function result

0 — message successfully submitted; -1 — CID does not exist or the network error occurred.


Example

Prohibition to send messages to a common conference "main" for all users except NSS rights group. If a user from another group sens a message to this conference it will be ignored, and they receive a console message about it in MyChat Client for Windows.

const
  NOTIFY_FLAG = true; // true/false: notify a user that he can't write messages in a conference
  RESTRICTED_CONFS = '|main|';
  ALLOWED_ROLES    = '|Administrators|Operators|NSS|';
  
function OnConfMessage(iCID, iUIN, iUID, iMsgType: integer; sConfName, sMsg: string): boolean;
var
  sRoleName: string;
  bFlag: boolean;
begin
  bFlag := true;
    if pos('|' + sConfName + '|', RESTRICTED_CONFS) <> 0 then begin
      sRoleName := mGetUserRoleName(iUIN);
        if pos('|' + sRoleName + '|', ALLOWED_ROLES) = 0 then begin
          bFlag := false;
          
            if NOTIFY_FLAG then 
              mSendCustomMsgToClientConsoleByCID(iCID, 
                                                 'Sorry, but you can not send messages to the conference #' + sConfName,
                                                 'Status', true, true, 4);
        end;  
    end;
    
  result := bFlag;  
end;

begin

end.


See also

mGetUserRoleName

Pos