1 | unit uClientInfo;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
---|
6 | uBrokerConnectionInfo, uRpcLogEntry, fClientRPCLogger;
|
---|
7 |
|
---|
8 |
|
---|
9 | type
|
---|
10 |
|
---|
11 | {
|
---|
12 | /// <summary>
|
---|
13 | /// Summary description for ClientInfo.
|
---|
14 | /// </summary>
|
---|
15 | }
|
---|
16 | TClientInfo = class(TPersistent)
|
---|
17 | private
|
---|
18 | FUniqueId: Integer;
|
---|
19 | FName: String;
|
---|
20 | FBrokerConnectionIndex: Integer;
|
---|
21 | FRpcHistoryEnabled: Boolean;
|
---|
22 | FRpcLogger: TfrmRpcClientLogger;
|
---|
23 | protected
|
---|
24 | function GetVisible: Boolean;
|
---|
25 | procedure SetVisible(Value: Boolean);
|
---|
26 | procedure Initialize;
|
---|
27 | public
|
---|
28 | Constructor Create; overload; virtual;
|
---|
29 | Constructor Create(uniqueId: Integer; name: String; connectionIndex: Integer; historyEnabled: Boolean); overload; virtual;
|
---|
30 | procedure AddRpcLogEntry(entry: TRpcLogEntry; overrideCheckBox: Boolean);
|
---|
31 | function MakeCheckBoxString: String;
|
---|
32 | function ToString: String;
|
---|
33 | property Visible: Boolean read GetVisible write SetVisible;
|
---|
34 | property Name: String read FName write FName;
|
---|
35 | property RpcHistoryEnabled: Boolean read FRpcHistoryEnabled write FRPCHistoryEnabled;
|
---|
36 | property UniqueId: Integer read FUniqueId write FUniqueId;
|
---|
37 | property BrokerConnectionIndex: Integer read FBrokerConnectionIndex write FBrokerConnectionIndex;
|
---|
38 | end;
|
---|
39 |
|
---|
40 | const
|
---|
41 | kRpcHistoryEnabledDefault: Boolean = true;
|
---|
42 | kBrokerConnectionIndexDefault: Integer = -1;
|
---|
43 |
|
---|
44 | implementation
|
---|
45 |
|
---|
46 | Constructor TClientInfo.Create;
|
---|
47 | begin
|
---|
48 | inherited;
|
---|
49 | Initialize;
|
---|
50 | end;
|
---|
51 | {
|
---|
52 | /// <summary>
|
---|
53 | /// ClientInfo parameterized constructor
|
---|
54 | /// </summary>
|
---|
55 | /// <param name="uniqueId"></param>
|
---|
56 | /// <param name="name"></param>
|
---|
57 | /// <param name="connectionIndex"></param>
|
---|
58 | /// <param name="historyEnabled"></param>
|
---|
59 | }
|
---|
60 | Constructor TClientInfo.Create(uniqueId: Integer; name: String; connectionIndex: Integer; historyEnabled: Boolean);
|
---|
61 | begin
|
---|
62 | Create;
|
---|
63 |
|
---|
64 | FUniqueId := uniqueId;
|
---|
65 | FName := name;
|
---|
66 | FBrokerConnectionIndex := connectionIndex;
|
---|
67 | FRpcHistoryEnabled := historyEnabled;
|
---|
68 | end;
|
---|
69 |
|
---|
70 | procedure TClientInfo.AddRpcLogEntry(entry: TRpcLogEntry; overrideCheckBox: Boolean);
|
---|
71 | begin
|
---|
72 | if(FRpcLogger <> nil) then
|
---|
73 | FRpcLogger.AddRpcLogEntry(entry, overrideCheckBox);
|
---|
74 | end;
|
---|
75 |
|
---|
76 | procedure TClientInfo.SetVisible(Value: Boolean);
|
---|
77 | begin
|
---|
78 | if(value) then
|
---|
79 | begin
|
---|
80 | if(FRpcLogger = nil) then
|
---|
81 | begin
|
---|
82 | FRpcLogger := TfrmRpcClientLogger.Create(Application);
|
---|
83 | // TODO FRpcLogger.OnRpcLoggerClose += new EventHandler(OnRpcLoggerClosedEventHandler);
|
---|
84 | FRpcLogger.Caption := 'RPC Log for '+Name+' ID='+IntToStr(UniqueId);
|
---|
85 | end;
|
---|
86 | FRpcLogger.Visible := true;
|
---|
87 | end
|
---|
88 | else
|
---|
89 | begin
|
---|
90 | if(FRpcLogger <> nil) then
|
---|
91 | begin
|
---|
92 | FRpcLogger.Visible := false;
|
---|
93 | FRpcLogger := nil;
|
---|
94 | end;
|
---|
95 | end;
|
---|
96 | end;
|
---|
97 |
|
---|
98 | function TClientInfo.GetVisible: Boolean;
|
---|
99 | begin
|
---|
100 | result := false;
|
---|
101 | if (FRpcLogger <> nil) then
|
---|
102 | result := FRpcLogger.Visible;
|
---|
103 | end;
|
---|
104 | {
|
---|
105 | /// <summary>
|
---|
106 | /// OnLogClosed is called when the ClientRpcLogger window is called
|
---|
107 | /// Any event handlers by owners of this object should assign
|
---|
108 | /// an event handler to this event
|
---|
109 | /// </summary>
|
---|
110 | }
|
---|
111 | // TODO
|
---|
112 | // public EventHandler OnLogClosed;
|
---|
113 | {
|
---|
114 | /// <summary>
|
---|
115 | /// MakeCheckBoxString creates a string based on the internal members
|
---|
116 | /// This string is intended to be used for check box list entries.
|
---|
117 | /// </summary>
|
---|
118 | /// <param name="checkBoxString"></param>
|
---|
119 | }
|
---|
120 | function TClientInfo.MakeCheckBoxString: String;
|
---|
121 | begin
|
---|
122 | Result := ToString;
|
---|
123 | end;
|
---|
124 |
|
---|
125 | {
|
---|
126 | /// <summary>
|
---|
127 | /// ToString returns a readable string representation of the member
|
---|
128 | /// </summary>
|
---|
129 | /// <returns></returns>
|
---|
130 | }
|
---|
131 | function TClientInfo.ToString: String;
|
---|
132 | begin
|
---|
133 | result := FName+' connection='+IntToStr(FBrokerConnectionIndex)+' id='+IntToStr(FUniqueId);
|
---|
134 | end;
|
---|
135 |
|
---|
136 | procedure TClientInfo.Initialize;
|
---|
137 | begin
|
---|
138 | FBrokerConnectionIndex := kBrokerConnectionIndexDefault;
|
---|
139 | FRpcHistoryEnabled := kRpcHistoryEnabledDefault;
|
---|
140 | FRpcLogger := nil;
|
---|
141 | end;
|
---|
142 |
|
---|
143 | // TODO
|
---|
144 | {
|
---|
145 | procedure TClientInfo.OnRpcLoggerClosedEventHandler(object sender, EventArgs e)
|
---|
146 | begin
|
---|
147 | // Pass the message on to my owner
|
---|
148 | Visible := false;
|
---|
149 | OnLogClosed(Self,nil);
|
---|
150 | end;
|
---|
151 | }
|
---|
152 |
|
---|
153 | end.
|
---|
154 |
|
---|