Skip to content

Commit 4a409dd

Browse files
Merge pull request #14 from comapi/dev
integrate ver 1.2.0
2 parents b5aa863 + 9474cb2 commit 4a409dd

31 files changed

+187
-248
lines changed

COMAPI/foundation/build.gradle

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,32 +39,27 @@ android {
3939
dependencies {
4040
compile fileTree(include: ['*.jar'], dir: 'libs')
4141
/* Android */
42-
compile 'com.android.support:appcompat-v7:26.0.1'
43-
42+
compile 'com.android.support:appcompat-v7:26.1.0'
4443
/* testing */
4544
testCompile 'junit:junit:4.12'
4645
androidTestCompile 'junit:junit:4.12'
47-
testCompile 'org.robolectric:robolectric:3.1.2'
48-
testCompile "org.robolectric:shadows-play-services:3.1.2"
49-
testCompile "org.robolectric:shadows-support-v4:3.1.2"
50-
androidTestCompile 'com.android.support.test:runner:0.5'
51-
androidTestCompile 'com.android.support.test:rules:0.5'
46+
testCompile 'org.robolectric:robolectric:3.2.2'
47+
testCompile 'org.robolectric:shadows-play-services:3.2.2'
48+
testCompile 'org.robolectric:shadows-support-v4:3.2.2'
49+
androidTestCompile 'com.android.support.test:runner:1.0.1'
50+
androidTestCompile 'com.android.support.test:rules:1.0.1'
5251
testCompile 'com.squareup.okhttp3:mockwebserver:3.9.0'
53-
52+
/* Rx */
53+
compile 'io.reactivex:rxjava:1.3.3'
54+
compile 'io.reactivex:rxandroid:1.2.1'
55+
compile 'com.squareup.retrofit2:adapter-rxjava:2.3.0'
5456
/* Network */
5557
compile 'com.squareup.retrofit2:retrofit:2.3.0'
5658
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
5759
compile 'com.squareup.okhttp3:logging-interceptor:3.6.0'
58-
compile 'com.squareup.retrofit2:adapter-rxjava:2.3.0'
59-
60-
/* RxJava */
61-
compile 'io.reactivex:rxjava:1.3.3'
62-
compile 'io.reactivex:rxandroid:1.2.1'
63-
6460
/*FCM*/
65-
compile 'com.google.android.gms:play-services-base:11.4.2'
66-
compile 'com.google.firebase:firebase-messaging:11.4.2'
67-
61+
compile 'com.google.android.gms:play-services-base:11.6.2'
62+
compile 'com.google.firebase:firebase-messaging:11.6.2'
6863
/*Sockets*/
6964
compile 'com.neovisionaries:nv-websocket-client:2.3'
7065
}

COMAPI/foundation/src/main/java/com/comapi/BaseClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public abstract class BaseClient<T> implements IClient<T> {
9797
/**
9898
* Adapter to dispatch events to multiple external listeners.
9999
*/
100-
private ListenerListAdapter listenerListAdapter;
100+
protected ListenerListAdapter listenerListAdapter;
101101

102102
/**
103103
* Recommended constructor.

COMAPI/foundation/src/main/java/com/comapi/BaseComapi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class BaseComapi {
3838
/**
3939
* Version of the ComapiImpl SDK MAJOR.MINOR.PATCH.BUILD
4040
*/
41-
private final static String SDK_VERSION = "1.1.1";
41+
private final static String SDK_VERSION = "1.2.0";
4242

4343
private static final Set<String> apiSpaces = Collections.synchronizedSet(new HashSet<String>());
4444

COMAPI/foundation/src/main/java/com/comapi/StateListener.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,26 @@ public abstract class StateListener implements IStateListener {
3636
*
3737
* @param session New session details.
3838
*/
39+
@Override
3940
public void onSessionStart(Session session) {}
4041

4142
/**
42-
* Socket started successfully.
43+
* Socket started successfully. Received confirmation event from the server.
4344
*
4445
* @param event Socket started successfully event.
4546
*/
47+
@Override
4648
public void onSocketStart(SocketStartEvent event) {}
4749

50+
/**
51+
* Socket disconnected.
52+
*/
53+
@Override
54+
public void onSocketDisconnected() {}
55+
56+
/**
57+
* Socket connected.
58+
*/
59+
@Override
60+
public void onSocketConnected() {}
4861
}

COMAPI/foundation/src/main/java/com/comapi/internal/IStateListener.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,19 @@
3131
public interface IStateListener extends ISessionListener {
3232

3333
/**
34-
* Socket started successfully.
34+
* Socket connected successfully.
3535
*
3636
* @param event Socket started successfully event.
3737
*/
3838
void onSocketStart(SocketStartEvent event);
3939

40+
/**
41+
* Socket disconnected.
42+
*/
43+
void onSocketConnected();
44+
45+
/**
46+
* Socket disconnected.
47+
*/
48+
void onSocketDisconnected();
4049
}

COMAPI/foundation/src/main/java/com/comapi/internal/ListenerListAdapter.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,30 @@ public void onSocketStarted(SocketStartEvent event) {
132132
}
133133
}
134134

135+
public void onSocketConnected() {
136+
log.d("TEST listener onSocketConnected triggered");
137+
for (IStateListener listener : stateListeners) {
138+
try {
139+
log.d("TEST listener onSocketConnected listener found");
140+
listener.onSocketConnected();
141+
} catch (Exception e) {
142+
logError(e, "socket connected");
143+
}
144+
}
145+
}
146+
147+
public void onSocketDisconnected() {
148+
log.d("TEST listener onSocketDisconnected triggered");
149+
for (IStateListener listener : stateListeners) {
150+
try {
151+
log.d("TEST listener onSocketDisconnected listener found");
152+
listener.onSocketDisconnected();
153+
} catch (Exception e) {
154+
logError(e, "socket disconnected");
155+
}
156+
}
157+
}
158+
135159
@Override
136160
public void onParticipantAdded(ParticipantAddedEvent event) {
137161
for (IMessagingListener listener : messagingListeners) {
@@ -292,6 +316,8 @@ public void removeListener(IProfileListener listener) {
292316
}
293317

294318
private void logError(Exception e, String details) {
295-
log.f("Couldn't deliver event ("+details+") Exception in external callback implementation.", e);
319+
if (log != null) {
320+
log.f("Couldn't deliver event (" + details + ") Exception in external callback implementation.", e);
321+
}
296322
}
297323
}

COMAPI/foundation/src/main/java/com/comapi/internal/log/FormatterConsoleLog.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ class FormatterConsoleLog extends Formatter {
3232
* Formats log message for console output. Short version.
3333
*
3434
* @param msgLogLevel Message log level.
35-
* @param clazz Class name in which message was logged.
35+
* @param module SDK module details
3636
* @param msg Log message.
3737
* @return Formatted log message.
3838
*/
39-
String formatMessage(int msgLogLevel, String clazz, String msg) {
40-
return getLevelTag(msgLogLevel) + "[" + clazz + "]: " + msg;
39+
String formatMessage(int msgLogLevel, String module, String msg) {
40+
return getLevelTag(msgLogLevel) + module + ": " + msg;
4141
}
4242
}

COMAPI/foundation/src/main/java/com/comapi/internal/log/FormatterFileLog.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ class FormatterFileLog extends Formatter {
4141
*/
4242
String formatMessage(int msgLogLevel, String tag, String msg, Throwable exception) {
4343
if (exception != null) {
44-
return DateHelper.getUTC(System.currentTimeMillis()) + getLevelTag(msgLogLevel) + "[" + tag + "] " + msg + "\n" + getStackTrace(exception) + "\n";
44+
return DateHelper.getUTC(System.currentTimeMillis()) + "/" + getLevelTag(msgLogLevel) + tag + ": " + msg + "\n" + getStackTrace(exception) + "\n";
4545
} else {
46-
return DateHelper.getUTC(System.currentTimeMillis()) + getLevelTag(msgLogLevel) + "[" + tag + "] " + msg + "\n";
46+
return DateHelper.getUTC(System.currentTimeMillis()) + "/" + getLevelTag(msgLogLevel) + tag + ": " + msg + "\n";
4747
}
4848
}
4949

COMAPI/foundation/src/main/java/com/comapi/internal/log/LogConstants.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,31 +31,31 @@ public interface LogConstants {
3131
/**
3232
* Default tag for {@link Logger}s
3333
*/
34-
String TAG = "Comapi";
34+
String TAG = "FDN";
3535

3636
/**
3737
* See {@link LogLevel#FATAL}
3838
*/
39-
String TAG_FATAL = "[FATAL]";
39+
String TAG_FATAL = "F/";
4040

4141
/**
4242
* See {@link LogLevel#ERROR}
4343
*/
44-
String TAG_ERROR = "[ERROR]";
44+
String TAG_ERROR = "E/";
4545

4646
/**
4747
* See {@link LogLevel#WARNING}
4848
*/
49-
String TAG_WARNING = "[WARNING]";
49+
String TAG_WARNING = "W/";
5050

5151
/**
5252
* See {@link LogLevel#INFO}
5353
*/
54-
String TAG_INFO = "[INFO]";
54+
String TAG_INFO = "I/";
5555

5656
/**
5757
* See {@link LogLevel#DEBUG}
5858
*/
59-
String TAG_DEBUG = "[DEBUG]";
59+
String TAG_DEBUG = "D/";
6060

6161
}

COMAPI/foundation/src/main/java/com/comapi/internal/network/ComapiResult.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ protected ComapiResult(T result, boolean isSuccessful, String eTag, int code, St
7878
if (response.errorBody() != null) {
7979
errorBody = response.errorBody().string();
8080
}
81-
} catch (IOException e) {
81+
} catch (Exception e) {
8282
e.printStackTrace();
8383
}
8484
}

0 commit comments

Comments
 (0)