-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
216 additions
and
305 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
inspector/src/main/java/com/taobao/weex/devtools/debug/CustomerWSClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package com.taobao.weex.devtools.debug; | ||
|
||
import com.taobao.weex.devtools.WeexInspector; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Created by moxun on 2017/6/12. | ||
*/ | ||
|
||
public class CustomerWSClient extends SocketClient { | ||
|
||
private IWebSocketClient webSocketClient; | ||
|
||
public CustomerWSClient(DebugServerProxy proxy) { | ||
super(proxy); | ||
webSocketClient = WeexInspector.getCustomerWSClient(); | ||
} | ||
|
||
@Override | ||
protected void connect(String url) { | ||
if (webSocketClient != null) { | ||
webSocketClient.connect(url, new IWebSocketClient.WSListener() { | ||
@Override | ||
public void onOpen() { | ||
if (mConnectCallback != null) { | ||
mConnectCallback.onSuccess(null); | ||
} | ||
} | ||
|
||
@Override | ||
public void onMessage(String message) { | ||
try { | ||
mProxy.handleMessage(message); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onClose() { | ||
if (mHandlerThread != null && mHandlerThread.isAlive()) { | ||
mHandler.sendEmptyMessage(CLOSE_WEB_SOCKET); | ||
} | ||
} | ||
|
||
@Override | ||
public void onFailure(Throwable cause) { | ||
if (mConnectCallback != null) { | ||
mConnectCallback.onFailure(cause); | ||
mConnectCallback = null; | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
|
||
@Override | ||
protected void close() { | ||
if (webSocketClient != null) { | ||
webSocketClient.close(); | ||
} | ||
} | ||
|
||
@Override | ||
protected void sendProtocolMessage(int requestID, String message) { | ||
if (webSocketClient != null) { | ||
webSocketClient.sendMessage(requestID, message); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean isOpen() { | ||
return webSocketClient != null && webSocketClient.isOpen(); | ||
} | ||
|
||
public boolean isAvailed() { | ||
return webSocketClient != null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
inspector/src/main/java/com/taobao/weex/devtools/debug/IWebSocketClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.taobao.weex.devtools.debug; | ||
|
||
/** | ||
* Created by moxun on 2017/6/12. | ||
*/ | ||
|
||
public interface IWebSocketClient { | ||
boolean isOpen(); | ||
void connect(String wsAddress, WSListener listener); | ||
void close(); | ||
void sendMessage(int requestId, String message); | ||
|
||
interface WSListener { | ||
void onOpen(); | ||
void onMessage(String message); | ||
void onClose(); | ||
void onFailure(Throwable cause); | ||
} | ||
} |
Oops, something went wrong.