summaryrefslogtreecommitdiff
path: root/packages/fcl-base/examples/dbugsrv.pp
blob: c54042595b2bb9ed7b691c9ff3cfe5ae0d7ecd91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
program dbugsrv;

{$MODE OBJFPC}
{$H+}
{$APPTYPE CONSOLE}

uses
  classes,SysUtils,simpleipc,dbugmsg;

Var
  Srv : TSimpleIPCServer;
  S : String;
  Msg : TDebugMessage;
  
begin
  Srv:=TSimpleIPCServer.Create(Nil);
  Try
    Srv.ServerID:=DebugServerID;
    Srv.Global:=True;
    Srv.Active:=True;
    Srv.StartServer;
    Writeln('Server started. Listening for debug messages');
    Repeat
      If Srv.PeekMessage(1,True) then
        begin
        Srv.MsgData.Seek(0,soFrombeginning);
        ReadDebugMessageFromStream(Srv.MsgData,MSg);
        Write(FormatDateTime('hh:nn:ss.zzz',Msg.MsgTimeStamp),': ');
        Write(DebugMessageName(MSg.MsgType):12,' ');
        Writeln(Msg.Msg);
        end
      else
        Sleep(10);
    Until False;
  Finally
    Srv.Free;
  end;
end.