procedure TCncMessageDispatcher.processMessage(meldung: TMeldung);
var
NewDataRecord : PNewDataRecord;
SendDataRecord : PNewDataRecord;
receivedMessage : TMeldung;
msg : tagMSG;
begin
receivedMessage := meldung;
try
New(NewDataRecord);
NewDataRecord^.ThreadID := GetCurrentThreadID;
NewDataRecord^.DataLength := Length(receivedMessage);
SetLength(NewDataRecord^.Data, Length(receivedMessage));
move(receivedMessage[0], NewDataRecord^.Data[0], NewDataRecord^.DataLength);
except
on e:
Exception do
raise Exception.Create(format('
Receiver thread error: %s',[e.
Message]));
end;
PostMessage( fDestHandle, TH_MESSAGE, TH_DATAM, Integer(NewDataRecord));
if (receivedMessage[0]
and $0F) = $06
then
begin
if PeekMessage(&msg, 0, 0, 0, PM_REMOVE)
then
begin
case msg.wParam
of
TTH_SEND:
begin
SendDataRecord := PNewDataRecord(msg.lParam);
fCommTest.transmitMessage(SendDataRecord^.Data);
end;
end;
end;
end;
PostMessage( fDestHandle, TH_MESSAGE, TH_CLOSE, GetCurrentThreadID );
end;