diff options
author | goblin911 <[email protected]> | 2013-08-25 21:16:45 +0800 |
---|---|---|
committer | goblin911 <[email protected]> | 2013-08-25 21:16:45 +0800 |
commit | 2efdc2f20f0306791ced5ec78a1acddfaf086f42 (patch) | |
tree | a85f2b32d6e6da9d7329ab975fea3bd79e1b94b6 /client/Socket-demo/Transam.java | |
parent | e5599da7fdd344fdcb49e8d6780a1e2ad358ee2d (diff) | |
parent | 263967cbb477983ae8680b431c1d93f102971c30 (diff) |
Merge branch 'master' of https://github.com/Determinant/piztor
Conflicts:
client/Piztor/bin/classes/com/macaroon/piztor/ActMgr.class
client/Piztor/bin/classes/com/macaroon/piztor/AppMgr.class
client/Piztor/bin/classes/com/macaroon/piztor/R$drawable.class
client/Piztor/bin/classes/com/macaroon/piztor/R$id.class
client/Piztor/bin/classes/com/macaroon/piztor/R$layout.class
client/Piztor/bin/classes/com/macaroon/piztor/R$menu.class
client/Piztor/bin/classes/com/macaroon/piztor/R$string.class
client/Piztor/gen/com/macaroon/piztor/R.java
client/Piztor/res/values/strings.xml
client/bin/classes/com/macaroon/piztor/ActStatus.class
client/bin/classes/com/macaroon/piztor/EmptyStatus.class
client/bin/classes/com/macaroon/piztor/Setting.class
client/src/com/macaroon/piztor/AppMgr.java
client/src/com/macaroon/piztor/Setting.java
Diffstat (limited to 'client/Socket-demo/Transam.java')
-rw-r--r-- | client/Socket-demo/Transam.java | 125 |
1 files changed, 0 insertions, 125 deletions
diff --git a/client/Socket-demo/Transam.java b/client/Socket-demo/Transam.java deleted file mode 100644 index b5e2381..0000000 --- a/client/Socket-demo/Transam.java +++ /dev/null @@ -1,125 +0,0 @@ -package com.example.test; - -import java.io.IOException; -import java.net.UnknownHostException; -import java.util.Timer; -import java.util.TimerTask; - -import android.annotation.SuppressLint; -import android.os.Handler; -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; - Thread thread; - 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; - ip = i; - req = r; - core = c; - } - - public void run() { - final thd t = new thd(); - flag = false; - thread = new Thread(t); - cnt = 4; - thread.start(); - timer = new Timer(); - TimerTask task = new Timertk(); - timer.schedule(task,2000,2000); - } - - class thd implements Runnable { - @Override - public void run() { - try{ - SocketClient client = new SocketClient(ip,port); - 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); - client.closeSocket(); - }catch (UnknownHostException e){ - }catch (IOException e){ - } - - } - } - - @SuppressLint("HandlerLeak") - Handler handler = new Handler(){ - public void handleMessage(Message msg) { - switch (msg.what) { - case 1: - flag = true; - break; - 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(); - thread = new Thread(t); - thread.start(); - break; - } - super.handleMessage(msg); - } - }; - - class Timertk extends TimerTask { - public void run() { - if(flag==false&&cnt>0){ - cnt--; - } - else if(cnt==0) { - Message msg = new Message(); - msg.obj = "connecting failed"; - msg.what = 2; - handler.sendMessage(msg); - timer.cancel(); - } - else if(flag==true){ - timer.cancel(); - } - } - }; -}
\ No newline at end of file |