unit GroupTestCase; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls, IdHTTP; type TForm3 = class(TForm) pgc1: TPageControl; ts1: TTabSheet; btn1: TButton; mmo1: TMemo; procedure btn1Click(Sender: TObject); private procedure ShakeHands; function HandleHandsShaking1(AStr: string): string; public { Public declarations } end; var Form3: TForm3; implementation uses LoggerImport, DateUtils, superobject; {$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; { TForm3 } procedure TForm3.btn1Click(Sender: TObject); begin ShakeHands; end; function TForm3.HandleHandsShaking1(AStr: string): string; var ACode: Byte; AStream: TStringStream; Len: Int64; begin Result := ''; AStream := TStringStream.Create(AStr); try AStream.Position :=1; Len := 0; AStream.Read(ACode, 1); while ACode <> $FF do begin Len := Len * 10; Inc(Len, ACode); AStream.Read(ACode, 1); end; //Code AStream.Read(ACode, 1); Result := AStream.ReadString(AStream.Size - AStream.Position); finally FreeAndNil(AStream); end; end; procedure TForm3.ShakeHands; var AIdHttp:TIdHTTP; ResponeStr: string; begin AIdHttp:= TIdHTTP.Create(nil); try ResponeStr := AIdHttp.get( Format('http://127.0.0.1:6714/socket.io/?uid=test&EIO=3&transport=polling&t=%d-0', [(DateTimeToUnix(Now) - 8*60*60) * 1000])); ResponeStr := HandleHandsShaking1(ResponeStr); mmo1.Lines.Add(UTF8Decode(ResponeStr)); ResponeStr := AIdHttp.get( Format('http://127.0.0.1:6714/socket.io/?uid=test&EIO=3&transport=polling&t=%d-0&sid=%s', [(DateTimeToUnix(Now) - 8*60*60) * 1000, SO(ResponeStr).S['sid']])); mmo1.Lines.Add(UTF8Decode(ResponeStr)); //http://127.0.0.1:6714/socket.io/?uid=test&EIO=3&transport=polling&t=1426413088298-1&sid=c1j056d1d2HzLjy8AAAa //ws://127.0.0.1:6714/socket.io/?uid=test&EIO=3&transport=websocket&sid=c1j056d1d2HzLjy8AAAa // FClient := TTestWebSocketClientConnection.Create(FIP, inttostr(FPort), '/socket.io/1/websocket/'+ResourceName,'-','ws'); // FClient.OnRead := OnRead; // FClient.OnWrite := OnWrite; // FClient.OnClose := OnClose; // FClient.OnOpen := OnOpen; except on E: Exception do begin Freeandnil(AIdHttp); // Error(E.Message, 'TGroup.Start'); Exit; end; end; Freeandnil(AIdHttp); end; end.