static void JobSendMessage(Args _args) { AOSSessionInfo testSession; int counter; int maxSessions; container users; int sesId; userId userId; ClientType clientKind; date logindate; int logintime; str clientComputerName; str databaseSpid; str itemSTr; userName userName; AOSClientMode clientMode; int sessionCount; int idleTicks; str recipient = curuserid();// place here addressee userid int recSesId = -1; ; [ users, maxSessions ] = SysUsersOnline::getAllOnlineUserInfo(); for(counter = 1; counter <= maxSessions; counter++) { [ sesId, userId, clientKind, loginDate, loginTime, clientComputerName, databaseSpid, userName, clientMode, idleTicks ] = conPeek(users, counter);
if(userId == recipient) { recSesId = sesId; break; } } if(recsesId != -1) { testSession = new AOSSessionInfo(recsesId); if (testSession) { AOSSessionInfo::sendMessage( recsesId, strfmt("@SYS55325", curuserid(), time2str(timenow(),0,0)),
"Hello!"); box::info("Delievered"); } } else { throw error(strFmt("User %1 is offline.", recipient)); } }
Borrowed from \Menu Items\Action\SysUsersSendMessage
Involved classes:
\Classes\SysUsersSendMessage
\Classes\SysUsersOnline
Copyright © 2008 Ruslan Goncharov