use of com.benmu.framework.adapter.ws.DefaultWebSocketAdapter in project WeexErosFramework by bmfe.
the class LightlyWebSocketAdapter method connect.
public void connect(String url, String protocol, EventListener listener, String instanceId) {
if (TextUtils.isEmpty(instanceId)) {
// invalidate instanceId
listener.onError(BMWSCode.INVALID_INSTANCEID.getReason());
return;
}
DefaultWebSocketAdapter defaultWebSocketAdapter = mAdapters.get(instanceId);
if (defaultWebSocketAdapter != null) {
// mutli adapter for this instanceId
// destory adapter
defaultWebSocketAdapter.destroy(BMWSCode.REPEAT_WEBSOCKET.getCode(), BMWSCode.REPEAT_WEBSOCKET.getReason());
newInstance(instanceId, url, protocol, listener);
// create
} else {
// create
newInstance(instanceId, url, protocol, listener);
}
}
use of com.benmu.framework.adapter.ws.DefaultWebSocketAdapter in project WeexErosFramework by bmfe.
the class LightlyWebSocketAdapter method newInstance.
private void newInstance(String instanceId, String url, String protocol, EventListener listener) {
DefaultWebSocketAdapter webSocketInstance = new DefaultWebSocketAdapter();
webSocketInstance.connect(url, protocol, listener, null);
mAdapters.put(instanceId, webSocketInstance);
}
use of com.benmu.framework.adapter.ws.DefaultWebSocketAdapter in project WeexErosFramework by bmfe.
the class LightlyWebSocketAdapter method onEvent.
@Subscribe
public void onEvent(Intent intent) {
if (WXConstant.ACTION_WEEX_REFRESH.equals(intent.getAction())) {
// refresh check mediator
String instanceId = intent.getStringExtra("instanceId");
if (!TextUtils.isEmpty(instanceId)) {
DefaultWebSocketAdapter defaultWebSocketAdapter = mAdapters.get(instanceId);
if (defaultWebSocketAdapter != null) {
// instance has destroy
defaultWebSocketAdapter.destroy(BMWSCode.INVALID_INSTANCEID.getCode(), BMWSCode.INVALID_INSTANCEID.getReason());
mAdapters.remove(instanceId);
}
}
}
}
use of com.benmu.framework.adapter.ws.DefaultWebSocketAdapter in project WeexErosFramework by bmfe.
the class DebuggerWebSocket method connect.
private void connect(String url) {
// connect when interceptor close
if (!Constant.INTERCEPTOR_ACTIVE.equals(SharePreferenceUtil.getInterceptorActive(BMWXEnvironment.mApplicationContext))) {
Log.e(TAG, "connecting");
mActice = true;
// create new instance when webSocketInstance has connected
if (webSocketInstance.isConnected()) {
webSocketInstance = new DefaultWebSocketAdapter();
}
webSocketInstance.connect(url, "", eventListent, new WSConfig(true, 10));
webSocketInstance.setConnected(true);
} else {
close();
mActice = false;
}
}
Aggregations