简体   繁体   English

查询在线游戏服务器以获取其状态Delphi-Indy 10

[英]Query to online game server to get its status Delphi - Indy 10

I am trying to find out how to establish a connection between a Delphi application and an online game server in this case Minecraft running with Bukkit. 我试图找出如何在Delphi应用程序和在线游戏服务器之间建立连接的方式,在本例中,该Minecraft与Bukkit一起运行。

The search was not successful, but I have a vague idea using maybe Indy 10 components? 搜索没有成功,但是我可能使用Indy 10组件有一个模糊的想法? like TIdTCPClient but I think it needs a handler, I dont know which one. 像TIdTCPClient一样,但我认为它需要一个处理程序,我不知道是哪个处理程序。

Then I want to ask. 然后我想问。

How to query an online server? 如何查询在线服务器?

With PHP: https://github.com/FunnyItsElmo/PHP-Minecraft-Server-Status-Query 使用PHP: https : //github.com/FunnyItsElmo/PHP-Minecraft-Server-Status-Query

Any idea coming up? 有什么想法吗?

Sorry for my English Thanks. 对不起,我的英文谢谢。

As MJN said, once you Connect() to the server, you use the TIdIOHandler.IOHandler property to read/write data as needed, eg: 正如MJN所说,一旦Connect()到服务器,就可以使用TIdIOHandler.IOHandler属性根据需要读取/写入数据,例如:

var
  data: TIdBytes;

Client.Host := AHost;
Client.Port := APort;
Client.ConnectTimeout := 3000;
Client.ReadTimeout := 3000;

Client.Connect;
try
  Client.IOHandler.Write(Byte($FE));
  Client.IOHandler.Write(Byte($01));
  Client.IOHandler.ReadBytes(data, 2048);
finally
  Client.Disconnect;
end;

// parse data as needed...

There is no additional "Handler" required for TIdTCPClient to connect with the server. TIdTCPClient不需要其他“处理程序”即可与服务器连接。

A TIdTCPClient instance contains an IOHandler (exposed as a property). TIdTCPClient实例包含一个IOHandler(作为属性公开)。

Use this IOHandler to read bytes from the server. 使用此IOHandler可以从服务器读取字节。

The PHP source code for Minecraft server status queries seems to be quite short and easy to understand, it will be no problem to port it to Delphi. 用于Minecraft服务器状态查询的PHP源代码似乎很短且易于理解,将其移植到Delphi不会有问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM