summaryrefslogtreecommitdiff
path: root/client/Socket-demo
diff options
context:
space:
mode:
authorMyth Yang <[email protected]>2013-08-23 15:08:35 +0800
committerMyth Yang <[email protected]>2013-08-23 15:08:46 +0800
commitc6c75af649359781e792cb841b44fb06631f08ad (patch)
tree067e94d8495fa000035185c4507dfe0fa1208560 /client/Socket-demo
parent34692fa869ae60e7c35e196542941df845e1fee7 (diff)
oops
Diffstat (limited to 'client/Socket-demo')
-rw-r--r--client/Socket-demo/Login.java6
-rw-r--r--client/Socket-demo/Transam.java31
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();