Improved mDNS response
This commit is contained in:
@@ -1,10 +1,18 @@
|
||||
package com.limelight;
|
||||
|
||||
import java.io.IOException;
|
||||
<<<<<<< HEAD
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
=======
|
||||
import java.net.SocketException;
|
||||
>>>>>>> d7062ac2e0b306c42144c84690a3735c5878e11d
|
||||
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import com.limelight.nvstream.NvConnection;
|
||||
import com.limelight.nvstream.NvHTTP;
|
||||
import com.limelight.nvstream.NvmDNS;
|
||||
|
||||
import android.os.Bundle;
|
||||
@@ -13,24 +21,28 @@ import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
public class Connection extends Activity {
|
||||
private Button statusButton;
|
||||
private Button statusButton, pairButton;
|
||||
private TextView hostText;
|
||||
private SharedPreferences prefs;
|
||||
|
||||
private static final String DEFAULT_HOST = "35.0.113.120";
|
||||
private static final String DEFAULT_HOST = "192.168.1.240";
|
||||
public static final String HOST_KEY = "hostText";
|
||||
|
||||
<<<<<<< HEAD
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
=======
|
||||
>>>>>>> d7062ac2e0b306c42144c84690a3735c5878e11d
|
||||
@Override
|
||||
public void onPause() {
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
@@ -65,8 +77,14 @@ public class Connection extends Activity {
|
||||
setContentView(R.layout.activity_connection);
|
||||
|
||||
|
||||
<<<<<<< HEAD
|
||||
// this.statusButton = (Button) findViewById(R.id.statusButton);
|
||||
// this.hostText = (TextView) findViewById(R.id.hostTextView);
|
||||
=======
|
||||
this.statusButton = (Button) findViewById(R.id.statusButton);
|
||||
this.pairButton = (Button) findViewById(R.id.pairButton);
|
||||
this.hostText = (TextView) findViewById(R.id.hostTextView);
|
||||
>>>>>>> d7062ac2e0b306c42144c84690a3735c5878e11d
|
||||
|
||||
//prefs = getPreferences(0);
|
||||
//this.hostText.setText(prefs.getString(Connection.HOST_KEY, Connection.DEFAULT_HOST));
|
||||
@@ -78,7 +96,65 @@ public class Connection extends Activity {
|
||||
intent.putExtra("host", Connection.this.hostText.getText().toString());
|
||||
Connection.this.startActivity(intent);
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
});*/
|
||||
=======
|
||||
});
|
||||
|
||||
this.pairButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
Toast.makeText(Connection.this, "Pairing...", Toast.LENGTH_LONG).show();
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String macAddress;
|
||||
try {
|
||||
macAddress = NvConnection.getMacAddressString();
|
||||
} catch (SocketException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
if (macAddress == null) {
|
||||
System.out.println("Couldn't find a MAC address");
|
||||
return;
|
||||
}
|
||||
|
||||
NvHTTP httpConn = new NvHTTP(hostText.getText().toString(), macAddress);
|
||||
|
||||
String message;
|
||||
try {
|
||||
if (httpConn.getPairState()) {
|
||||
message = "Already paired";
|
||||
}
|
||||
else {
|
||||
int session = httpConn.getSessionId();
|
||||
if (session == 0) {
|
||||
message = "Pairing was declined by the target";
|
||||
}
|
||||
else {
|
||||
message = "Pairing was successful";
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
message = e.getMessage();
|
||||
} catch (XmlPullParserException e) {
|
||||
message = e.getMessage();
|
||||
}
|
||||
|
||||
final String toastMessage = message;
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(Connection.this, toastMessage, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
});
|
||||
>>>>>>> d7062ac2e0b306c42144c84690a3735c5878e11d
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user