[829] | 1 | unit uBrokerConnectionInfo;
|
---|
| 2 |
|
---|
| 3 | interface
|
---|
| 4 |
|
---|
| 5 | uses Windows, Classes, SysUtils, uRpcLogEntry, fClientRPCLogger, Forms;
|
---|
| 6 |
|
---|
| 7 | Type
|
---|
| 8 | {
|
---|
| 9 | TRPCLogEntry = class
|
---|
| 10 | end;
|
---|
| 11 | }
|
---|
| 12 | TClientRPCLogger = class
|
---|
| 13 | private
|
---|
| 14 | FText: String;
|
---|
| 15 | FVisible: Boolean;
|
---|
| 16 | public
|
---|
| 17 | procedure AddRpcLogEntry(entry: TRpcLogEntry; overrideCheckBox: Boolean);
|
---|
| 18 | property Text: String read FText write FText;
|
---|
| 19 | property Visible: Boolean read FVisible write FVisible;
|
---|
| 20 | end;
|
---|
| 21 |
|
---|
| 22 | TBrokerConnectionInfo = class(TPersistent)
|
---|
| 23 | private
|
---|
| 24 | FRpcLogger: TfrmRPCClientLogger;
|
---|
| 25 | FConnectionIndex: Integer;
|
---|
| 26 | FConnectedServerIp: String;
|
---|
| 27 | FConnectedServerPort: Integer;
|
---|
| 28 | FLastContext: String;
|
---|
| 29 | protected
|
---|
| 30 | function GetVisible: Boolean;
|
---|
| 31 | procedure SetVisible(Value: Boolean);
|
---|
| 32 | public
|
---|
| 33 | Constructor Create(); overload; virtual;
|
---|
| 34 | Constructor Create(index: Integer; ip: String; port: Integer; lastContext: String); overload; virtual;
|
---|
| 35 | function MakeListItemString: String; virtual;
|
---|
| 36 | function ToString: String;
|
---|
| 37 | procedure AddRpcLogEntry(entry: TRpcLogEntry; overrideCheckBox: bool);
|
---|
| 38 | property ConnectionIndex: Integer read FConnectionIndex write FConnectionIndex;
|
---|
| 39 | property ConnectedServerIp: String read FConnectedServerIP write FConnectedServerIP;
|
---|
| 40 | property ConnectedServerPort: Integer read FConnectedServerPort write FConnectedServerPort;
|
---|
| 41 | property LastContext: String read FLastContext write FLastContext;
|
---|
| 42 | property Visible: Boolean read GetVisible write SetVisible;
|
---|
| 43 | end;
|
---|
| 44 |
|
---|
| 45 |
|
---|
| 46 | const
|
---|
| 47 | kNoConnectionIndex = -1;
|
---|
| 48 | kNoServerIp: String = '0.0.0.0';
|
---|
| 49 | kNoConnectedServerPort: Integer = 0;
|
---|
| 50 | kNoLastContext: String = 'NO CONTEXT';
|
---|
| 51 |
|
---|
| 52 | implementation
|
---|
| 53 |
|
---|
| 54 | Constructor TBrokerConnectionInfo.Create;
|
---|
| 55 | begin
|
---|
| 56 | ConnectionIndex := kNoConnectionIndex;
|
---|
| 57 | ConnectedServerIp := kNoServerIp;
|
---|
| 58 | ConnectedServerPort := kNoConnectedServerPort;
|
---|
| 59 | LastContext := kNoLastContext;
|
---|
| 60 | end;
|
---|
| 61 |
|
---|
| 62 | {
|
---|
| 63 | /// <summary>
|
---|
| 64 | /// BrokerConnectionInfo is the parameterized constructor
|
---|
| 65 | /// </summary>
|
---|
| 66 | /// <param name="index"></param>
|
---|
| 67 | /// <param name="ip"></param>
|
---|
| 68 | /// <param name="port'></param>
|
---|
| 69 | /// <param name='lastContext'></param>
|
---|
| 70 | }
|
---|
| 71 | Constructor TBrokerConnectionInfo.Create(index: Integer; ip: String; port: Integer; lastContext: String);
|
---|
| 72 | begin
|
---|
| 73 | FConnectionIndex := index;
|
---|
| 74 | FConnectedServerIp := ip;
|
---|
| 75 | FConnectedServerPort := port;
|
---|
| 76 | FLastContext := lastContext;
|
---|
| 77 | end;
|
---|
| 78 |
|
---|
| 79 | {
|
---|
| 80 | /// <summary>
|
---|
| 81 | /// MakeListItemString makes a string from its members intended
|
---|
| 82 | /// to be used for list items in a list box
|
---|
| 83 | /// </summary>
|
---|
| 84 | /// <param name='listItemString'></param>
|
---|
| 85 | }
|
---|
| 86 | function TBrokerConnectionInfo.MakeListItemString: String;
|
---|
| 87 | begin
|
---|
| 88 | Result := ToString;
|
---|
| 89 | end;
|
---|
| 90 |
|
---|
| 91 | {
|
---|
| 92 | /// <summary>
|
---|
| 93 | /// ToString returns a readable string format of the member data
|
---|
| 94 | /// </summary>
|
---|
| 95 | /// <returns></returns>
|
---|
| 96 | }
|
---|
| 97 | function TBrokerConnectionInfo.ToString: String;
|
---|
| 98 | begin
|
---|
| 99 | Result := IntToStr(ConnectionIndex)+' server IP='+ConnectedServerIp+' server port='+IntToStr(ConnectedServerPort)+' last context='+LastContext;
|
---|
| 100 | end;
|
---|
| 101 |
|
---|
| 102 | {
|
---|
| 103 | /// <summary>
|
---|
| 104 | /// AddRpcLogEntry adds a single log entry to the broker connection
|
---|
| 105 | /// visual log box
|
---|
| 106 | /// </summary>
|
---|
| 107 | /// <param name='entry'></param>
|
---|
| 108 | /// <param name='overrideCheckBox'></param>
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 | procedure TBrokerConnectionInfo.AddRpcLogEntry(entry: TRpcLogEntry; overrideCheckBox: bool);
|
---|
| 112 | begin
|
---|
| 113 | if(FRpcLogger <> nil) then
|
---|
| 114 | FRpcLogger.AddRpcLogEntry(entry,overrideCheckBox);
|
---|
| 115 | end;
|
---|
| 116 |
|
---|
| 117 | procedure TBrokerConnectionInfo.SetVisible(Value: Boolean);
|
---|
| 118 | begin
|
---|
| 119 | if (value) then
|
---|
| 120 | begin
|
---|
| 121 | if(FRpcLogger = nil) then
|
---|
| 122 | begin
|
---|
| 123 | FRpcLogger := TfrmRpcClientLogger.Create(Application);
|
---|
| 124 | // ?? FRpcLogger.OnRpcLoggerClose += new EventHandler(OnRpcLoggerClosedEventHandler);
|
---|
| 125 | FRpcLogger.Caption := 'RPC Log for connection '+IntToStr(ConnectionIndex);
|
---|
| 126 | end;
|
---|
| 127 | FRpcLogger.Visible := true;
|
---|
| 128 | end
|
---|
| 129 | else
|
---|
| 130 | if(FRpcLogger <> nil) then
|
---|
| 131 | begin
|
---|
| 132 | FRpcLogger.Visible := false;
|
---|
| 133 | FRpcLogger := nil;
|
---|
| 134 | end;
|
---|
| 135 | end;
|
---|
| 136 |
|
---|
| 137 | function TBrokerConnectionInfo.GetVisible: Boolean;
|
---|
| 138 | begin
|
---|
| 139 | result := false;
|
---|
| 140 | if(FRpcLogger <> nil) then
|
---|
| 141 | result := FRpcLogger.Visible;
|
---|
| 142 | end;
|
---|
| 143 |
|
---|
| 144 | {
|
---|
| 145 | /// <summary>
|
---|
| 146 | /// OnLogClosed is called when the ClientRpcLogger window is called
|
---|
| 147 | /// Any event handlers by owners of this object should assign
|
---|
| 148 | /// an event handler to this event
|
---|
| 149 | /// </summary>
|
---|
| 150 | }
|
---|
| 151 | { // TODO
|
---|
| 152 | procedure EventHandler OnLogClosed;
|
---|
| 153 | private void OnRpcLoggerClosedEventHandler(object sender, EventArgs e)
|
---|
| 154 | begin
|
---|
| 155 | // Pass the message on to my owner
|
---|
| 156 | Visible := false;
|
---|
| 157 | OnLogClosed(Self,nil);
|
---|
| 158 | end;
|
---|
| 159 | }
|
---|
| 160 |
|
---|
| 161 | procedure TClientRPCLogger.AddRpcLogEntry(entry: TRPCLogEntry; overrideCheckBox: Boolean);
|
---|
| 162 | begin
|
---|
| 163 | // TODO
|
---|
| 164 | end;
|
---|
| 165 |
|
---|
| 166 | end.
|
---|