Skip to content

Commit 6de7611

Browse files
committed
Accept port number when discovering server
1 parent d12f84e commit 6de7611

4 files changed

Lines changed: 5 additions & 4 deletions

File tree

.idea/misc.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/uk/co/digitme/machinemonitoring/Helpers/ServerDiscovery.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,11 @@ public static boolean findServer(Context context) {
8989

9090
//Check if the message is correct
9191
String message = new String(receivePacket.getData()).trim();
92-
if (message.equals(DISCOVERY_RESPONSE_MESSAGE)) {
92+
String[] split = message.split(":",2);
93+
if (split[0].equals(DISCOVERY_RESPONSE_MESSAGE)) {
9394
ip = receivePacket.getAddress().toString();
9495
Log.v(TAG, "HOST IP IS " + ip);
95-
String address = "http://" + ip + ":80"; // todo support other ports
96+
String address = "http://" + ip + ":" + split[1];
9697
//Save the ip as a preference
9798
dbHelper.saveServerAddress(address);
9899
return true;

app/src/main/java/uk/co/digitme/machinemonitoring/MainActivity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ public void run() {
142142
if (success){
143143
checkState();
144144
mStatusText.setText("Server address found. Connecting...");
145+
mAddressText.setText(dbHelper.getServerAddress());
145146
} else {
146147
showError("Server discovery failed");
147148
}

app/src/main/res/layout/activity_login.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@
9999
android:fontFamily="@string/form_font_family" />
100100
</LinearLayout>
101101

102-
103-
<!--todo show the failure reason in a text view. A toast isnt visible enough.-->
104102
<uk.co.digitme.machinemonitoring.Helpers.CustomNumpadView
105103
android:id="@+id/keyboard_view"
106104
android:layout_width="wrap_content"

0 commit comments

Comments
 (0)