| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- unit GroupTestCase;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, ComCtrls, IdHTTP,WebSocket2,WebSocketClient,synautil,
- Buttons, Sockets;
- type
- TProtocolMethod = procedure(Data: String) of Object;
- TForm3 = class(TForm)
- pgc1: TPageControl;
- ts1: TTabSheet;
- btn1: TButton;
- mmo1: TMemo;
- btn6: TBitBtn;
- btn2: TBitBtn;
- udpsckt1: TUdpSocket;
- procedure btn1Click(Sender: TObject);
- procedure btn6Click(Sender: TObject);
- procedure btn7Click(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure btn2Click(Sender: TObject);
- private
- FClient: TWebSocketClientConnection;
- FLoginNames: TStrings;
- FGroupClients: TList;
- public
- { Public declarations }
- end;
- var
- Form3: TForm3;
- implementation
- uses
- //LoggerImport
- DateUtils ,superobject, GroupClient, GroupUtility;
- const
- SUBSCRIBE_PROTOCOL: string = '5:::{"name":"group.subscribe","args":{"id":"%s"}}';
- {$R *.dfm}
- const
- CONNECT: Byte = 0;
- DISCONNECT: Byte = 1;
- EVENT: Byte = 2;
- ACK: Byte = 3;
- ERROR: Byte = 4;
- BINARY_EVENT: Byte = 5;
- BINARY_ACK: Byte = 6;
- MAX_PROTOCOL_NUM: Byte = 6;
- MIN_PROTOCOL_NUM: Byte = 0;
- type
- TLoginTestCase = class(TThread)
- public
- procedure Execute; override;
- end;
- { TForm3 }
- procedure TForm3.btn1Click(Sender: TObject);
- var
- ALoginTestCase: TLoginTestCase;
- begin
- ALoginTestCase := TLoginTestCase.Create(False);
- end;
- procedure TForm3.btn2Click(Sender: TObject);
- var
- AMemebers: TStringList;
- begin
- AMemebers := TStringList.Create;
- AMemebers.Add('Member01');
- TGroupClient(FGroupClients[0]).CreateTeam('test', '12', '2323', AMemebers, False);
- FreeAndNil(AMemebers);
- end;
- procedure TForm3.btn6Click(Sender: TObject);
- var
- iLoop: Integer;
- AGroupClient: TGroupClient;
- begin
- AGroupClient := TGroupClient.Create;
- AGroupClient.Connect(FLoginNames[0]);
- FGroupClients.Add(AGroupClient);
- end;
- procedure TForm3.btn7Click(Sender: TObject);
- var
- AMemebers: TStringList;
- begin
- AMemebers := TStringList.Create;
- AMemebers.Add('Test1');
- TGroupClient(FGroupClients[0]).CreateTeam('test', '12', '2323', AMemebers, False);
- FreeAndNil(AMemebers);
- end;
- procedure TForm3.FormCreate(Sender: TObject);
- var
- iLoop: Integer;
- begin
- FLoginNames := TStringList.Create;
- FGroupClients := TList.Create;
- for iLoop := 0 to 10000 - 1 do
- begin
- FLoginNames.Add('User' + IntToStr(iLoop));
- end;
- end;
- { TLoginTestCase }
- procedure TLoginTestCase.Execute;
- var
- iLoop: Integer;
- AGroupClient: TGroupClient;
- begin
- for iLoop := 0 to 1000 - 1 do
- begin
- AGroupClient := TGroupClient.Create;
- AGroupClient.Connect(Form3.FLoginNames[iLoop]);
- Form3.FGroupClients.Add(AGroupClient);
- end;
- end;
- end.
|