| Line | |
|---|
| 1 | package com.example.helloandroid;
|
|---|
| 2 |
|
|---|
| 3 | import common.*;
|
|---|
| 4 |
|
|---|
| 5 | /*
|
|---|
| 6 | * This thread is responsible for interacting with the server. It waits to receive messages from the server and then handles them.
|
|---|
| 7 | */
|
|---|
| 8 |
|
|---|
| 9 | public class ClientThread extends Connection {
|
|---|
| 10 | private Game main;
|
|---|
| 11 |
|
|---|
| 12 | public ClientThread(String ip, int port, Game main) {
|
|---|
| 13 | super(ip, port, "ClientThread");
|
|---|
| 14 |
|
|---|
| 15 | this.main = main;
|
|---|
| 16 | }
|
|---|
| 17 |
|
|---|
| 18 | protected void processMessage(MessageType type, String input) {
|
|---|
| 19 |
|
|---|
| 20 | }
|
|---|
| 21 |
|
|---|
| 22 | protected void connectionStart() {
|
|---|
| 23 | main.mThread.connMessage = "Connection Started";
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | protected void connectionSuccess() {
|
|---|
| 27 | main.mThread.connMessage = "Connected to Server";
|
|---|
| 28 | sendMessage(MessageType.Info, "Yo, youze beeze gay!");
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | protected void connectionFailure(String str) {
|
|---|
| 32 | main.mThread.connMessage = "Server not found";
|
|---|
| 33 | main.mThread.connMessage = str;
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | protected void connectionBreak() {
|
|---|
| 37 | main.mThread.connMessage = "Your connection was interrupted";
|
|---|
| 38 | }
|
|---|
| 39 |
|
|---|
| 40 | protected void peerDisconnect() {
|
|---|
| 41 | main.mThread.connMessage = "The server disconnected";
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 | protected void connectionEnd() {
|
|---|
| 45 |
|
|---|
| 46 | }
|
|---|
| 47 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.