我正忙于开发一个Android应用程序,用户可以在其中查看PC游戏Formula 1 2017的游戏内数据。我能够设置一个UDP接收器,该接收器从游戏中接收数据,但输出看起来像是编码。
如何解析下面网址中列出的数据?
我正在使用以下网址: http://forums.codemasters.com/discussion/53139/f1-2017-d-box-and-udp-output-specification
这是我的接收方代码:
class GetUDPData extends AsyncTask<Void, byte[], Void> {
int UDPPort = 20777;
Context context;
TextView tvLog;
public GetUDPData(Context context_) {
context = context_;
tvLog = (TextView) ((Activity) context).findViewById(R.id.tvLog);
}
@Override
protected void onProgressUpdate(byte[]... values) {
if (!isCancelled()) {
new ParseUDPData(context, values[0]);
}
super.onProgressUpdate(values);
}
@Override
protected Void doInBackground(Void... params) {
try {
DatagramSocket socket = new DatagramSocket(UDPPort);
byte[] receiveData = new byte[1289];
while (!isCancelled()) {
DatagramPacket packet = new DatagramPacket(receiveData, receiveData.length);
socket.receive(packet);
publishProgress(packet.getData());
}
} catch (Exception e) {
Log.d("UDP - ERROR", e.toString());
}
return null;
}
@Override
protected void onPreExecute() {
tvLog.append("Listening on IP: " + Utils.getIPAddress(true) + " and Port: " + UDPPort);
super.onPreExecute();
}
}