procedure TCliCon.ProcessMessage(nMsgID: Byte; ptrData: Pointer; cbSize: DWORD);
var
nKeepAlive: Byte;
DataRec: TDataRec;
begin
try
if nMsgID = MSG_ID_DATA
then begin
try
if Assigned(@ServerObj.CBData)
then begin
FillChar(DataRec, SizeOf(TDataRec), 0);
DataRec.Socket := FSocket.SocketHandle;
DataRec.ptrData := ptrData;
DataRec.cbSize := cbSize;
DataRec.ptrLogonSVRRec := @FLogonRec;
ServerObj.CBData(@DataRec);
end;
except
on e:
exception do begin
if Assigned(@ServerObj.CBClientError)
then begin
FillChar(DataRec, SizeOf(TDataRec), 0);
DataRec.Socket := FSocket.SocketHandle;
DataRec.Error := WSAGetLastError;
DataRec.ErrorMsg := PChar(
'
EXCEPTION > $0228 [MSG_ID_DATA] : ' + e.
Message
);
ServerObj.CBClientError(@DataRec);
end;
try FSocket.Close
except end;
end;
end;
end else
if nMsgID = MSG_ID_LOGON
then begin
try
move(ptrData^, FLogonRec, SizeOf(TLogonSVRRec));
FLogonRec.ptrClientObj := FSocket;
FStringHash.Add(FLogonRec.GUID, self);
if Assigned(@ServerObj.CBLogon)
then begin
FillChar(DataRec, SizeOf(TDataRec), 0);
DataRec.Socket := FSocket.SocketHandle;
DataRec.ptrData := ptrData;
DataRec.cbSize := cbSize;
DataRec.ptrLogonSVRRec := @FLogonRec;
ServerObj.CBLogon(@DataRec);
end;
except
on e:
exception do begin
if Assigned(@ServerObj.CBClientError)
then begin
FillChar(DataRec, SizeOf(TDataRec), 0);
DataRec.Socket := FSocket.SocketHandle;
DataRec.Error := WSAGetLastError;
DataRec.ErrorMsg := PChar(
'
EXCEPTION > $0227 [MSG_ID_LOGON] : ' + e.
Message
);
ServerObj.CBClientError(@DataRec);
end;
try FSocket.Close
except end;
end;
end;
end else
if nMsgID = MSG_ID_KEEP_ALLIVE
then begin
try
//-- KeepAllive Retournieren
SendMsg(MSG_ID_KEEP_ALLIVE, @nKeepAlive, SizeOf(Byte));
except
on e:
exception do begin
if Assigned(@ServerObj.CBClientError)
then begin
FillChar(DataRec, SizeOf(TDataRec), 0);
DataRec.Socket := FSocket.SocketHandle;
DataRec.Error := WSAGetLastError;
DataRec.ErrorMsg := PChar(
'
EXCEPTION > $0228 [MSG_ID_KEEP_ALLIVE] : ' + e.
Message
);
ServerObj.CBClientError(@DataRec);
end;
try FSocket.Close
except end;
end;
end;
end;
except
on e:
exception do begin
if Assigned(@ServerObj.CBClientError)
then begin
FillChar(DataRec, SizeOf(TDataRec), 0);
DataRec.Socket := FSocket.SocketHandle;
DataRec.Error := WSAGetLastError;
DataRec.ErrorMsg := PChar(
'
EXCEPTION > TCliCon.ProcessMessage [GENERAL] : 1449 ' + e.
Message
);
ServerObj.CBClientError(@DataRec);
end;
end;
end;
end;