Delphi RCON Client

· 컴포넌트

sgcWebSockets 4.5.1부터 RCON 프로토콜이 지원돼요. Source RCON 프로토콜은 Source Dedicated Server에서 사용하는 TCP/IP 기반 통신 프로토콜로, "원격 콘솔" 또는 RCON을 통해 서버에 콘솔 명령을 발행할 수 있어요. RCON의 가장 일반적인 용도는 서버 소유자가 서버가 실행 중인 머신에 직접 접근하지 않고 게임 서버를 제어할 수 있도록 하는 것이에요.

설정 

RCON_Options에서 다음 속성들을 설정할 수 있어요:


연결

서버에 연결/연결 해제하려면 Active 속성을 사용하세요.

Active가 True로 설정되면 클라이언트가 서버에 연결을 시도하고, 연결할 수 있으면 제공된 비밀번호로 인증을 시도해요.

서버는 인증 요청에 응답을 보내고 OnAuthenticate 이벤트가 호출돼요. Authenticate 매개변수를 사용해 인증이 성공했는지 확인할 수 있어요.


명령 보내기 

서버에 명령을 보내려면 ExecCommand 메서드를 사용하세요. 응답은 OnResponse 이벤트에서 확인할 수 있어요.

oRCON := TsgcLib_RCON.Create(nil);
oRCON.RCON_Options.Host := '127.0.0.1';
oRCON.RCON_Options.Port := 25575;
oRCON.RCON_Options.Password := 'test';
oRCON.Active := True;
procedure OnAuthenticate(Sender: TObject; Authenticated: Boolean; const aPacket: TsgcRCON_Packet);
begin
  if Authenticated then
    DoLog('#authenticated')
  else
    DoLog('#not authenticated');
end;
procedure OnResponse(Sender: TObject; const aResponse: string; const aPacket: TsgcRCON_Packet);
begin
  DoLog(aResponse);
end;