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