Last active
August 29, 2015 14:17
-
-
Save matthewrkula/97f295dfa721b85e6626 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
final Socket socket = serverSocket.accept(); | |
final boolean[] accept = { false }; | |
new Handler(Looper.getMainLooper()).post(() -> { | |
new AlertDialog.Builder(lobbyActivity) | |
.setTitle("Incoming Request") | |
.setMessage("Incoming Game Request") | |
.setPositiveButton(android.R.string.yes, (dialog, which) -> { | |
accept[0] = true; | |
try { | |
socket.getOutputStream().write( 1); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
new Handler(Looper.getMainLooper()).post(() -> { | |
Log.d("GAME", "Starting game from connection."); | |
AndroidLauncher.network = new NetworkHandler(socket); | |
Intent intent = new Intent(lobbyActivity, AndroidLauncher.class); | |
lobbyActivity.startActivity(intent); | |
}); | |
}) | |
.setNegativeButton(android.R.string.no, (dialog, which) -> { | |
accept[0] = false; | |
try { | |
socket.getOutputStream().write(0); | |
socket.close(); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
}) | |
.setIcon(android.R.drawable.ic_dialog_alert) | |
.show(); | |
}); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment