summaryrefslogtreecommitdiff
path: root/client/Socket-demo
diff options
context:
space:
mode:
authorTeddy <[email protected]>2013-08-23 21:15:01 +0800
committerTeddy <[email protected]>2013-08-23 21:15:01 +0800
commit9f239db4b690e648db9c3a2df6b0ee7f26edb0c2 (patch)
treeea4f14c857608acb637ddd27f1251d55d244b231 /client/Socket-demo
parent12b1d4bc7e56c7de8bf325f702cff1ae114c4db0 (diff)
parente76d8dc824fddada5912eb838a49d77e7f73641e (diff)
Merge branch 'master' of github.com:Determinant/piztor
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();