diff options
Diffstat (limited to 'client/Socket-demo')
-rw-r--r-- | client/Socket-demo/Login.java | 6 | ||||
-rw-r--r-- | client/Socket-demo/Transam.java | 31 |
2 files changed, 35 insertions, 2 deletions
diff --git a/client/Socket-demo/Login.java b/client/Socket-demo/Login.java new file mode 100644 index 0000000..2dd386c --- /dev/null +++ b/client/Socket-demo/Login.java @@ -0,0 +1,6 @@ +package com.example.test; + +public class Login{ + void success(int t){} + void failed(){} +}
\ No newline at end of file diff --git a/client/Socket-demo/Transam.java b/client/Socket-demo/Transam.java index 6f0fb44..b5e2381 100644 --- a/client/Socket-demo/Transam.java +++ b/client/Socket-demo/Transam.java @@ -12,6 +12,7 @@ import android.os.Message; public class Transam implements Runnable { public Timer timer; public boolean flag = true; + public boolean reqlog = false; public int cnt = 4; public int port; public String ip; @@ -19,6 +20,16 @@ public class Transam implements Runnable { Myrequest req; Myrespond res; Controller core; + Login log; + + + Transam(String i,int p,Myrequest r,Login l){ + port = p; + ip = i; + req = r; + log = l; + reqlog = true; + } Transam(String i,int p,Myrequest r,Controller c){ port = p; @@ -43,8 +54,19 @@ public class Transam implements Runnable { public void run() { try{ SocketClient client = new SocketClient(ip,port); - res = client.sendMsg(req); + res = client.sendMsg(req); + if(!reqlog){ core.recieveInfo(res); + } + else{ + if((Integer) res.contain.get(2)==0){ + int t = (Integer) res.contain.get(1); + log.success(t); + } + else{ + log.failed(); + } + } Message msg = new Message(); msg.what = 1; handler.sendMessage(msg); @@ -63,10 +85,15 @@ public class Transam implements Runnable { case 1: flag = true; break; - case 2: + case 2: + if(!reqlog){ res = new Myrespond(); res.wrong = msg.obj.toString(); core.recieveInfo(res); + } + else{ + log.failed(); + } break; case 3: final thd t = new thd(); |