Skip to content

Commit bb5afb1

Browse files
committed
-Update bbox change where we open websocket
-Add websocket isClose()
1 parent 06c891c commit bb5afb1

File tree

8 files changed

+120
-126
lines changed

8 files changed

+120
-126
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@ This is the basic SDK for your own application if you want to make use of BboxAP
66

77
1 -jar file
88
clone the depot and build
9-
add **bboxapi-library-1.1-release.aar** to your lib folder of your project
9+
add **bboxapi-library-1.2-release.aar** to your lib folder of your project
1010
add this line to your gradle dependencies
1111
````
12-
compile(name: 'bboxapi-debug', ext: 'aar')
12+
compile(name: 'bboxapi-library-1.2-release.aar', ext: 'aar')
1313
````
1414
2 -maven
1515
````
1616
<dependency>
1717
<groupId>fr.bouyguestelecom.dev</groupId>
1818
<artifactId>bboxapi</artifactId>
19-
<version>1.1</version>
19+
<version>1.2</version>
2020
<type>pom</type>
2121
</dependency>
2222
````
2323
3 -jcenter
2424
````
25-
compile 'fr.bouyguestelecom.dev:bboxapi:1.1'
25+
compile 'fr.bouyguestelecom.dev:bboxapi:1.2'
2626
````
2727
### Prerequisites
2828

bboxapi/bboxapi.iml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
8282
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
8383
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
84-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
8584
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
8685
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
8786
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
@@ -94,6 +93,7 @@
9493
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
9594
<excludeFolder url="file://$MODULE_DIR$/build/libs" />
9695
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
96+
<excludeFolder url="file://$MODULE_DIR$/build/poms" />
9797
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
9898
</content>
9999
<orderEntry type="jdk" jdkName="Android API 25 Platform" jdkType="Android SDK" />

bboxapi/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ android {
1010
minSdkVersion 14
1111
targetSdkVersion 25
1212
versionCode 2
13-
versionName "1.1"
13+
versionName "1.2"
1414
}
1515
buildTypes {
1616
release {

bboxapi/proguard-rules.pro

Lines changed: 0 additions & 17 deletions
This file was deleted.

bboxapi/src/main/java/tv/bouyguestelecom/fr/bboxapilibrary/Bbox.java

Lines changed: 90 additions & 85 deletions
Large diffs are not rendered by default.

bboxapi/src/main/java/tv/bouyguestelecom/fr/bboxapilibrary/ws/WebSocket.java

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import tv.bouyguestelecom.fr.bboxapilibrary.callback.IBboxApplication;
2020
import tv.bouyguestelecom.fr.bboxapilibrary.callback.IBboxMedia;
2121
import tv.bouyguestelecom.fr.bboxapilibrary.callback.IBboxMessage;
22+
import tv.bouyguestelecom.fr.bboxapilibrary.callback.IBboxSubscribe;
2223
import tv.bouyguestelecom.fr.bboxapilibrary.model.ApplicationResource;
2324
import tv.bouyguestelecom.fr.bboxapilibrary.model.MediaResource;
2425
import tv.bouyguestelecom.fr.bboxapilibrary.model.MessageResource;
@@ -36,26 +37,23 @@ public class WebSocket {
3637

3738
private String mAppId;
3839
private String mWebsocketAddress;
40+
private final IBboxSubscribe iBboxSubscribe;
3941

40-
public WebSocket(String ip, String appId) {
42+
public WebSocket(String ip, String appId, IBboxSubscribe iBboxSubscribe) {
4143
mAppId = appId;
4244
mWebsocketAddress = WEBSOCKET_PREFIX + ip + ":" + WEBSOCKET_PORT;
45+
this.iBboxSubscribe = iBboxSubscribe;
4346
init();
4447
}
4548

46-
public static WebSocket getInstance(String appId, Bbox bbox) {
47-
if(instance == null) {
48-
instance = new WebSocket(appId, appId);
49-
}
50-
51-
return instance;
52-
}
53-
5449
private void init() {
5550
mWebSocketClient = new WebSocketClient(URI.create(mWebsocketAddress)) {
5651
@Override
5752
public void onOpen(ServerHandshake handshakedata) {
5853
mWebSocketClient.send(mAppId);
54+
if (iBboxSubscribe != null) {
55+
iBboxSubscribe.onSubscribe();
56+
}
5957
}
6058

6159
@Override
@@ -87,11 +85,12 @@ public void onMessage(String message) {
8785

8886
if (obj.get("resourceId").toString().contains("Message") || obj.get("resourceId").toString().contains(".")) {
8987

90-
MessageResource messageResource = new MessageResource(obj.getJSONObject("body").get("source").toString(),
91-
obj.getJSONObject("body").get("message").toString());
88+
JSONObject body = obj.getJSONObject("body");
89+
MessageResource messageResource = new MessageResource(body.get("source").toString(),
90+
body.getString("message"));
9291

93-
for (Map.Entry<String, IBboxMessage> iMsgListenerEntry : Bbox.getInstance().getNotifMsg().getMap().entrySet()) {
94-
iMsgListenerEntry.getValue().onNewMessage(messageResource);
92+
for (IBboxMessage msg : Bbox.getInstance().getNotifMsg().getMap().values()) {
93+
msg.onNewMessage(messageResource);
9594
}
9695
}
9796

@@ -117,7 +116,7 @@ public void onClose(int code, String reason, boolean remote) {
117116

118117
@Override
119118
public void onError(Exception ex) {
120-
Log.e(TAG, "onError");
119+
Log.e(TAG, "onError", ex);
121120
}
122121
};
123122

@@ -130,6 +129,13 @@ public void close() {
130129
}
131130
}
132131

133-
134-
132+
public boolean isClosed() {
133+
if (mWebSocketClient != null) {
134+
org.java_websocket.WebSocket realWebSocket = mWebSocketClient.getConnection();
135+
if (realWebSocket != null) {
136+
return realWebSocket.isClosed();
137+
}
138+
}
139+
return true;
140+
}
135141
}

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ buildscript {
66
mavenCentral()
77
}
88
dependencies {
9-
classpath 'com.android.tools.build:gradle:2.2.3'
9+
classpath 'com.android.tools.build:gradle:2.3.1'
1010
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
1111
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
1212
// NOTE: Do not place your application dependencies here; they belong

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

0 commit comments

Comments
 (0)