【发布时间】:2016-03-19 14:33:36
【问题描述】:
您好,我正在使用 AndEngine 多人游戏扩展开发 MultiplayerGame,我需要客户端在连接到服务器时从服务器获取一些数据
现在如何从服务器获取一些数据?当客户端连接到服务器时,我需要获取一些 int 或 String 数据
只有这个代码:
// Listener - states when we (as a client) have connected to a server
@Override
public void onStarted(ServerConnector<SocketConnection> pServerConnector) {
Log.i(TAG, "Connected To :" + pServerConnector.getConnection().getSocket().getInetAddress().getHostAddress().toString());
}
和
// Listener - In the event of a client connecting
@Override
public void onStarted(ClientConnector<SocketConnection> pClientConnector) {
Log.i(TAG, "Client Connected From : " + pClientConnector.getConnection().getSocket().getInetAddress().getHostAddress());
}
【问题讨论】:
-
看看 Volley developer.android.com/training/volley/index.html。当然,您还需要一些服务器功能来提供数据。有关 REST 服务的文献可能是该任务的良好开端。
-
Tnx 但它关于 AndEngine(Android 的 2D 游戏引擎)和本地网络上的 Socket 编程,所以我认为 Volly 无能为力!
标签: android andengine multiplayer