android网络层实现实例
2010-09-13 17:36
441 查看
本文通过网络破解工具反编译获得,阅读免责声明并同意后,方可阅读。
免责声明:本人不负责该文章带来的任何法律责任,仅供学习之用,不得传播并用于商业用途,请于24小时内删除。
public class MsgFrame
implements
Runnable
{
static private java.io.DataOutputStream dos;
static AgEncrypt m_Ag;
public String IP;
dialog.GamePrompt NetError;
public int PORT;
byte[] buffer;
private java.io.DataInputStream dis;
android.os.Handler handler;
android.os.Handler mHandler;
private java.net.Socket mSocket;
public boolean m_bServiceStop;
long reciveHeart;
byte[] recvbuffer;
long sendHeart;
Thread thread;
public MsgFrame(android.content.Context c1) {
MsgFrame$1 m2;
MsgFrame$2 m3;
GamePrompt g4;
IP = "127.0.0.1";
PORT = 12345;
m_bServiceStop = null;
sendHeart = 65535;
reciveHeart = 65535;
m2 = new MsgFrame$1(this);
handler = m2;
m3 = new MsgFrame$2(this);
mHandler = m3;
initPara();
m_Ag = new AgEncrypt();
g4 = new dialog.GamePrompt(c1);
NetError = g4;
NetError.setText("/u7f03/u6220/u7cb6/u6769/u70b4/u5e34");
NetError.setType(1);
}
static public int SendMsg(byte[] b1) {
Object o2;
java.io.DataOutputStream o3;
int i1;
Exception e1;
o2 = null;
if (b1 != null) goto L18;
o3 = o2;
L16:
return o3;
L18:
o3 = dos;
if (o3 == null) {
o3 = o2;
goto L16;
}
if (b1 != null) {
try {
o3 = b1.length;
if (o3 > 0) {
dos.write(b1);
o3 = dos;
o3.flush();
}
}
}
L57:
i1 = 1;
goto L16;
catch (e1) {
e1.printStackTrace();
goto L57;
}
}
static public void SendPacket(byte[] b1, int i2) {
int i3;
int i4;
int i5;
int i6;
byte[] b7;
byte[] b10;
byte[] b11;
i3 = 12;
i4 = 8;
i5 = 4;
i6 = 0;
if ((b1 != null) && (b1.length > 0)) goto L70;
b7 = new byte[i3];
zym.insertIntToPack(i2, b7, i6);
zym.insertIntToPack(b7.length, b7, i5);
zym.insertIntToPack(i6, b7, i4);
MsgFrame.SendMsg(b7);
L69:
return;
L70:
l8 = b1.length;
l9 += 12;
b10 = new byte[l8];
zym.insertIntToPack(i2, b10, i6);
zym.insertIntToPack(b10.length, b10, i5);
zym.insertIntToPack(i6, b10, i4);
b11 = m_Ag.encrypt(b1);
l12 = b11.length;
System.arraycopy(b11, i6, b10, i3, l12);
MsgFrame.SendMsg(b10);
goto L69;
}
private void initPara() {
try {
if (mSocket != null) {
mSocket.close();
mSocket = null;
}
if (dis != null) {
dis.close();
dis = null;
}
if (dos != null) {
dos.close();
dos = null;
}
}
for (;;) {
return;
catch.printStackTrace();
}
}
public boolean CreatSocket() {
int i1;
Object o2;
boolean b3;
int i1;
String s1;
int i6;
InetSocketAddress i7;
Socket s3;
InputStream i9;
DataInputStream d2;
OutputStream o11;
DataOutputStream d2;
StringBuilder s1;
String s14;
int i15;
long l3;
int i2;
UnknownHostException u19;
Object o2;
IOException i21;
i1 = 1;
o2 = null;
b3 = m_bServiceStop;
if (b3 == false) goto L25;
i1 = i1;
L23:
return i1;
L25:
initPara();
try {
s1 = IP;
i6 = PORT;
i7 = new java.net.InetSocketAddress(s1, i6);
s3 = new java.net.Socket();
mSocket = s3;
mSocket.connect(i7, 5000);
i9 = mSocket.getInputStream();
d2 = new java.io.DataInputStream(i9);
dis = d2;
o11 = mSocket.getOutputStream();
d2 = new java.io.DataOutputStream(o11);
dos = d2;
}
s1 = new StringBuilder("Connect success,ip = ");
s14 = IP;
s1 = s1.append(s14).append(",PORT = ");
i15 = PORT;
zym.pt(s1.append(i15).toString());
l3 = System.currentTimeMillis();
sendHeart = l17;
l3 = System.currentTimeMillis();
reciveHeart = l17;
i2 = i1;
goto L23;
catch (u19) {
u19.printStackTrace();
StopService();
zym.pt(u19.toString());
o2 = o2;
goto L23;
}
catch (i21) {
StopService();
i21.printStackTrace();
zym.pt(i21.toString());
o2 = o2;
goto L23;
}
}
public void StartService() {
Thread t1;
zym.pt("StartService");
if (m_bServiceStop == false) {
m_bServiceStop = true;
t1 = new Thread(this, "MsgFrameThread");
thread = t1;
thread.start();
}
}
public void StopService() {
zym.pt("StopService()");
m_bServiceStop = null;
initPara();
}
public void dealPackage(int i1, byte[] b2) {
long l3;
Message m5;
Message m6;
switch (i1) {
default:
if (mSwitchView.mGameTable != null) {
mSwitchView.mGameTable.recPack(i1, b2);
}
L256:
return;
case 2:
l3 = System.currentTimeMillis();
reciveHeart = l4;
goto L256;
case 4:
if (mSwitchView.mLoginView == null) goto L256;
mSwitchView.mLoginView.ResponseLogin(b2);
goto L256;
case 10:
m5 = new android.os.Message();
m5.obj = b2;
m5.what = i1;
mHandler.sendMessage(m5);
goto L256;
case 15:
if (mSwitchView.mChanelListView == null) goto L256;
mSwitchView.mChanelListView.LoginLobbyResponse(b2);
goto L256;
case 1105:
if (mSwitchView.mChanelListView == null) goto L256;
mSwitchView.mChanelListView.CreatRoleResponse(b2);
goto L256;
case 24:
if (mSwitchView.mLobbyView == null) goto L256;
mSwitchView.mLobbyView.TableListResponse(i1, b2);
goto L256;
case 209:
if (mSwitchView.mLobbyView != null) {
mSwitchView.mLobbyView.TableChangeInfo(i1, b2);
}
if (mSwitchView.mTabInsideView == null) goto L256;
mSwitchView.mTabInsideView.modifyPlayerNum(i1, b2);
goto L256;
case 104:
if (mSwitchView.mLobbyView == null) goto L256;
mSwitchView.mLobbyView.TableDestroy(i1, b2);
goto L256;
case 215:
if (mSwitchView.mLobbyView == null) goto L256;
mSwitchView.mLobbyView.LobbyMsg(i1, b2);
goto L256;
case 213:
if (mSwitchView.mLobbyView == null) goto L256;
mSwitchView.mLobbyView.UserChat(i1, b2);
goto L256;
case 719:
if (mSwitchView.mLobbyView == null) goto L256;
mSwitchView.mLobbyView.UserTitle(i1, b2);
goto L256;
case 102:
if (mSwitchView.mLobbyView == null) goto L256;
mSwitchView.mLobbyView.CreatTableResponse(i1, b2);
goto L256;
case 103:
if (mSwitchView.mLobbyView == null) goto L256;
mSwitchView.mLobbyView.CreatTableInside(i1, b2);
goto L256;
case 107:
if (mSwitchView.mTabInsideView == null) goto L256;
mSwitchView.mTabInsideView.setOtherUser(i1, b2);
goto L256;
case 1211:
case 1209:
case 1202:
case 1201:
case 501:
case 211:
case 210:
case 206:
case 204:
case 108:
if (mSwitchView.mTabInsideView != null) {
mSwitchView.mTabInsideView.dealPackage(i1, b2);
}
else {
if ((i1 != 1202) || (mSwitchView.mLobbyView == null)) goto L256;
mSwitchView.mLobbyView.setTableInsideValue(i1, b2);
}
goto L256;
case 109:
m6 = new android.os.Message();
m6.obj = b2;
m6.what = i1;
mHandler.sendMessage(m6);
goto L256;
case 106:
if (mSwitchView.mLobbyView == null) goto L256;
mSwitchView.mLobbyView.EnterTableResponse(i1, b2);
goto L256;
}
if (mSwitchView.mLobbyView == null) goto L256;
mSwitchView.mLobbyView.QuickEnterTableResponse(i1, b2);
goto L256;
}
public void run() {
long l1;
long l2;
long l4;
long l6;
long l7;
for (;;) {
if (m_bServiceStop == false) {
return;
}
try {
xRecvNew();
l1 = System.currentTimeMillis();
l2 = sendHeart;
if (((l3 - l2) - 30000) > 0) {
MsgFrame.SendPacket(null, 1);
l4 = System.currentTimeMillis();
sendHeart = l5;
zym.pt("Send Heart Package ");
}
l6 = System.currentTimeMillis();
l7 = reciveHeart;
if (((l8 - l7) - -20536) <= 0) continue;
handler.sendEmptyMessage(null);
zym.pt("net down");
}
continue;
catch.printStackTrace();
}
}
public void setIPAndPort(String s1, int i2) {
IP = s1;
PORT = i2;
}
public void xRecvNew() throws Exception {
int i1;
int i2;
Object o3;
DataInputStream d4;
DataInputStream d1;
int i3;
Exception e7;
StringBuilder s8;
String s9;
int i6;
byte[] b1;
DataInputStream d1;
DataInputStream d1;
byte[] b15;
int i16;
int i17;
String s4;
byte[] b1;
DataInputStream d1;
DataInputStream d1;
byte[] b22;
int i2;
byte[] b24;
byte[] b25;
int i26;
byte[] b27;
StringBuilder s28;
String s29;
StringBuilder s30;
String s31;
i1 = 8;
i2 = 12;
monitorenter(this);
o3 = null;
try {
d4 = dis;
if (d4 != null) {
d1 = dis;
i3 = d1.available();
}
}
if (i3 >= i2) goto L107;
L46:
monitorexit(this);
return;
catch (e7) {
e7.printStackTrace();
s8 = new StringBuilder("1");
s9 = e7.toString();
zym.pt(s8.append(s9).toString());
handler.sendEmptyMessage(0);
goto L46;
}
finally {
monitorexit(this);
throw l10;
}
L107:
i6 = 8;
try {
b1 = new byte[i6];
buffer = b1;
try {
}
d1 = dis;
if (d1 != null) {
d1 = dis;
b15 = buffer;
d1.read(b15);
}
try {
}
i16 = zym.getIntFromPack(buffer, 0);
i17 = zym.getIntFromPack(buffer, 4);
s4 = new StringBuilder("cmd = ").append(i16).append(", len = ").append(i17).toString();
zym.pt(s4);
if (i17 <= 0) goto L46;
b1 = new byte[(i17 - i1)];
recvbuffer = b1;
try {
}
d1 = dis;
if (d1 != null) {
d1 = dis;
b22 = recvbuffer;
d1.readFully(b22);
}
}
i2 = i17 - i2;
try {
b24 = new byte[i2];
b25 = recvbuffer;
i26 = i17 - i2;
System.arraycopy(i2, 4, b24, 0, i2);
b27 = m_Ag.decrypt(b24);
dealPackage(i16, b27);
}
goto L46;
catch;
catch;
(e7 = catch);
e7.printStackTrace();
zym.pt("receive error");
goto L46;
catch (e7) {
try {
e7.printStackTrace();
s28 = new StringBuilder("2");
s29 = e7.toString();
zym.pt(s28.append(s29).toString());
handler.sendEmptyMessage(0);
goto L46;
}
catch (e7) {
e7.printStackTrace();
s30 = new StringBuilder("3");
s31 = e7.toString();
zym.pt(s30.append(s31).toString());
handler.sendEmptyMessage(0);
}
}
goto L46;
}
}
免责声明:本人不负责该文章带来的任何法律责任,仅供学习之用,不得传播并用于商业用途,请于24小时内删除。
public class MsgFrame
implements
Runnable
{
static private java.io.DataOutputStream dos;
static AgEncrypt m_Ag;
public String IP;
dialog.GamePrompt NetError;
public int PORT;
byte[] buffer;
private java.io.DataInputStream dis;
android.os.Handler handler;
android.os.Handler mHandler;
private java.net.Socket mSocket;
public boolean m_bServiceStop;
long reciveHeart;
byte[] recvbuffer;
long sendHeart;
Thread thread;
public MsgFrame(android.content.Context c1) {
MsgFrame$1 m2;
MsgFrame$2 m3;
GamePrompt g4;
IP = "127.0.0.1";
PORT = 12345;
m_bServiceStop = null;
sendHeart = 65535;
reciveHeart = 65535;
m2 = new MsgFrame$1(this);
handler = m2;
m3 = new MsgFrame$2(this);
mHandler = m3;
initPara();
m_Ag = new AgEncrypt();
g4 = new dialog.GamePrompt(c1);
NetError = g4;
NetError.setText("/u7f03/u6220/u7cb6/u6769/u70b4/u5e34");
NetError.setType(1);
}
static public int SendMsg(byte[] b1) {
Object o2;
java.io.DataOutputStream o3;
int i1;
Exception e1;
o2 = null;
if (b1 != null) goto L18;
o3 = o2;
L16:
return o3;
L18:
o3 = dos;
if (o3 == null) {
o3 = o2;
goto L16;
}
if (b1 != null) {
try {
o3 = b1.length;
if (o3 > 0) {
dos.write(b1);
o3 = dos;
o3.flush();
}
}
}
L57:
i1 = 1;
goto L16;
catch (e1) {
e1.printStackTrace();
goto L57;
}
}
static public void SendPacket(byte[] b1, int i2) {
int i3;
int i4;
int i5;
int i6;
byte[] b7;
byte[] b10;
byte[] b11;
i3 = 12;
i4 = 8;
i5 = 4;
i6 = 0;
if ((b1 != null) && (b1.length > 0)) goto L70;
b7 = new byte[i3];
zym.insertIntToPack(i2, b7, i6);
zym.insertIntToPack(b7.length, b7, i5);
zym.insertIntToPack(i6, b7, i4);
MsgFrame.SendMsg(b7);
L69:
return;
L70:
l8 = b1.length;
l9 += 12;
b10 = new byte[l8];
zym.insertIntToPack(i2, b10, i6);
zym.insertIntToPack(b10.length, b10, i5);
zym.insertIntToPack(i6, b10, i4);
b11 = m_Ag.encrypt(b1);
l12 = b11.length;
System.arraycopy(b11, i6, b10, i3, l12);
MsgFrame.SendMsg(b10);
goto L69;
}
private void initPara() {
try {
if (mSocket != null) {
mSocket.close();
mSocket = null;
}
if (dis != null) {
dis.close();
dis = null;
}
if (dos != null) {
dos.close();
dos = null;
}
}
for (;;) {
return;
catch.printStackTrace();
}
}
public boolean CreatSocket() {
int i1;
Object o2;
boolean b3;
int i1;
String s1;
int i6;
InetSocketAddress i7;
Socket s3;
InputStream i9;
DataInputStream d2;
OutputStream o11;
DataOutputStream d2;
StringBuilder s1;
String s14;
int i15;
long l3;
int i2;
UnknownHostException u19;
Object o2;
IOException i21;
i1 = 1;
o2 = null;
b3 = m_bServiceStop;
if (b3 == false) goto L25;
i1 = i1;
L23:
return i1;
L25:
initPara();
try {
s1 = IP;
i6 = PORT;
i7 = new java.net.InetSocketAddress(s1, i6);
s3 = new java.net.Socket();
mSocket = s3;
mSocket.connect(i7, 5000);
i9 = mSocket.getInputStream();
d2 = new java.io.DataInputStream(i9);
dis = d2;
o11 = mSocket.getOutputStream();
d2 = new java.io.DataOutputStream(o11);
dos = d2;
}
s1 = new StringBuilder("Connect success,ip = ");
s14 = IP;
s1 = s1.append(s14).append(",PORT = ");
i15 = PORT;
zym.pt(s1.append(i15).toString());
l3 = System.currentTimeMillis();
sendHeart = l17;
l3 = System.currentTimeMillis();
reciveHeart = l17;
i2 = i1;
goto L23;
catch (u19) {
u19.printStackTrace();
StopService();
zym.pt(u19.toString());
o2 = o2;
goto L23;
}
catch (i21) {
StopService();
i21.printStackTrace();
zym.pt(i21.toString());
o2 = o2;
goto L23;
}
}
public void StartService() {
Thread t1;
zym.pt("StartService");
if (m_bServiceStop == false) {
m_bServiceStop = true;
t1 = new Thread(this, "MsgFrameThread");
thread = t1;
thread.start();
}
}
public void StopService() {
zym.pt("StopService()");
m_bServiceStop = null;
initPara();
}
public void dealPackage(int i1, byte[] b2) {
long l3;
Message m5;
Message m6;
switch (i1) {
default:
if (mSwitchView.mGameTable != null) {
mSwitchView.mGameTable.recPack(i1, b2);
}
L256:
return;
case 2:
l3 = System.currentTimeMillis();
reciveHeart = l4;
goto L256;
case 4:
if (mSwitchView.mLoginView == null) goto L256;
mSwitchView.mLoginView.ResponseLogin(b2);
goto L256;
case 10:
m5 = new android.os.Message();
m5.obj = b2;
m5.what = i1;
mHandler.sendMessage(m5);
goto L256;
case 15:
if (mSwitchView.mChanelListView == null) goto L256;
mSwitchView.mChanelListView.LoginLobbyResponse(b2);
goto L256;
case 1105:
if (mSwitchView.mChanelListView == null) goto L256;
mSwitchView.mChanelListView.CreatRoleResponse(b2);
goto L256;
case 24:
if (mSwitchView.mLobbyView == null) goto L256;
mSwitchView.mLobbyView.TableListResponse(i1, b2);
goto L256;
case 209:
if (mSwitchView.mLobbyView != null) {
mSwitchView.mLobbyView.TableChangeInfo(i1, b2);
}
if (mSwitchView.mTabInsideView == null) goto L256;
mSwitchView.mTabInsideView.modifyPlayerNum(i1, b2);
goto L256;
case 104:
if (mSwitchView.mLobbyView == null) goto L256;
mSwitchView.mLobbyView.TableDestroy(i1, b2);
goto L256;
case 215:
if (mSwitchView.mLobbyView == null) goto L256;
mSwitchView.mLobbyView.LobbyMsg(i1, b2);
goto L256;
case 213:
if (mSwitchView.mLobbyView == null) goto L256;
mSwitchView.mLobbyView.UserChat(i1, b2);
goto L256;
case 719:
if (mSwitchView.mLobbyView == null) goto L256;
mSwitchView.mLobbyView.UserTitle(i1, b2);
goto L256;
case 102:
if (mSwitchView.mLobbyView == null) goto L256;
mSwitchView.mLobbyView.CreatTableResponse(i1, b2);
goto L256;
case 103:
if (mSwitchView.mLobbyView == null) goto L256;
mSwitchView.mLobbyView.CreatTableInside(i1, b2);
goto L256;
case 107:
if (mSwitchView.mTabInsideView == null) goto L256;
mSwitchView.mTabInsideView.setOtherUser(i1, b2);
goto L256;
case 1211:
case 1209:
case 1202:
case 1201:
case 501:
case 211:
case 210:
case 206:
case 204:
case 108:
if (mSwitchView.mTabInsideView != null) {
mSwitchView.mTabInsideView.dealPackage(i1, b2);
}
else {
if ((i1 != 1202) || (mSwitchView.mLobbyView == null)) goto L256;
mSwitchView.mLobbyView.setTableInsideValue(i1, b2);
}
goto L256;
case 109:
m6 = new android.os.Message();
m6.obj = b2;
m6.what = i1;
mHandler.sendMessage(m6);
goto L256;
case 106:
if (mSwitchView.mLobbyView == null) goto L256;
mSwitchView.mLobbyView.EnterTableResponse(i1, b2);
goto L256;
}
if (mSwitchView.mLobbyView == null) goto L256;
mSwitchView.mLobbyView.QuickEnterTableResponse(i1, b2);
goto L256;
}
public void run() {
long l1;
long l2;
long l4;
long l6;
long l7;
for (;;) {
if (m_bServiceStop == false) {
return;
}
try {
xRecvNew();
l1 = System.currentTimeMillis();
l2 = sendHeart;
if (((l3 - l2) - 30000) > 0) {
MsgFrame.SendPacket(null, 1);
l4 = System.currentTimeMillis();
sendHeart = l5;
zym.pt("Send Heart Package ");
}
l6 = System.currentTimeMillis();
l7 = reciveHeart;
if (((l8 - l7) - -20536) <= 0) continue;
handler.sendEmptyMessage(null);
zym.pt("net down");
}
continue;
catch.printStackTrace();
}
}
public void setIPAndPort(String s1, int i2) {
IP = s1;
PORT = i2;
}
public void xRecvNew() throws Exception {
int i1;
int i2;
Object o3;
DataInputStream d4;
DataInputStream d1;
int i3;
Exception e7;
StringBuilder s8;
String s9;
int i6;
byte[] b1;
DataInputStream d1;
DataInputStream d1;
byte[] b15;
int i16;
int i17;
String s4;
byte[] b1;
DataInputStream d1;
DataInputStream d1;
byte[] b22;
int i2;
byte[] b24;
byte[] b25;
int i26;
byte[] b27;
StringBuilder s28;
String s29;
StringBuilder s30;
String s31;
i1 = 8;
i2 = 12;
monitorenter(this);
o3 = null;
try {
d4 = dis;
if (d4 != null) {
d1 = dis;
i3 = d1.available();
}
}
if (i3 >= i2) goto L107;
L46:
monitorexit(this);
return;
catch (e7) {
e7.printStackTrace();
s8 = new StringBuilder("1");
s9 = e7.toString();
zym.pt(s8.append(s9).toString());
handler.sendEmptyMessage(0);
goto L46;
}
finally {
monitorexit(this);
throw l10;
}
L107:
i6 = 8;
try {
b1 = new byte[i6];
buffer = b1;
try {
}
d1 = dis;
if (d1 != null) {
d1 = dis;
b15 = buffer;
d1.read(b15);
}
try {
}
i16 = zym.getIntFromPack(buffer, 0);
i17 = zym.getIntFromPack(buffer, 4);
s4 = new StringBuilder("cmd = ").append(i16).append(", len = ").append(i17).toString();
zym.pt(s4);
if (i17 <= 0) goto L46;
b1 = new byte[(i17 - i1)];
recvbuffer = b1;
try {
}
d1 = dis;
if (d1 != null) {
d1 = dis;
b22 = recvbuffer;
d1.readFully(b22);
}
}
i2 = i17 - i2;
try {
b24 = new byte[i2];
b25 = recvbuffer;
i26 = i17 - i2;
System.arraycopy(i2, 4, b24, 0, i2);
b27 = m_Ag.decrypt(b24);
dealPackage(i16, b27);
}
goto L46;
catch;
catch;
(e7 = catch);
e7.printStackTrace();
zym.pt("receive error");
goto L46;
catch (e7) {
try {
e7.printStackTrace();
s28 = new StringBuilder("2");
s29 = e7.toString();
zym.pt(s28.append(s29).toString());
handler.sendEmptyMessage(0);
goto L46;
}
catch (e7) {
e7.printStackTrace();
s30 = new StringBuilder("3");
s31 = e7.toString();
zym.pt(s30.append(s31).toString());
handler.sendEmptyMessage(0);
}
}
goto L46;
}
}
相关文章推荐
- 【Android 网络数据解析实现一个简单的新闻实例(一)】
- Android实现网络多线程断点续传下载实例
- Android 实现仿网络直播弹幕功能详解及实例
- Android 网络通信API的选择和实现实例
- Android中AsyncTask的简单用法及实现网络图片下载的实例
- Android中实现下载URL地址的网络资源的实例分享
- 【Android 网络数据解析实现一个简单的新闻实例(一)】
- Android编程实现网络图片查看器和网页源码查看器实例
- 使用Vitamio开源项目在Android实现播放网络视频
- Android开发实现拍照功能的方法实例解析
- Android实现网络多线程断点续传下载
- Android 实现监听的四种方法详解实例代码
- 一个android网络登录实例代码
- 实例讲解Android中如何实现图片的异步加载功能
- Android网络:HTTP之利用HttpURLConnection访问网页、获取网络图片实例 (附源码)
- Android 通过网络图片路径查看图片实例详解
- Android开发本地及网络Mp3音乐播放器(十五)网络音乐及歌词下载功能实现
- android 检查网络连接状态实现步骤
- Android网络编程之UrlConnection【实例解析】
- Retrofit2.0+RxJava+Dragger2实现不一样的Android网络架构搭建