Skip to content

Commit 0e2a87c

Browse files
committed
Fixed a bug which crashed when closing an app with leaving a connection open
1 parent 6a7dcef commit 0e2a87c

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

src/android/com/knowledgecode/cordova/websocket/DestroyTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void execute(String rawArgs, CallbackContext ctx) {
5151
int key = _map.keyAt(i);
5252

5353
if (_map.get(key).isOpen()) {
54-
_map.get(key).close();
54+
_map.get(key).close(true);
5555
}
5656
}
5757
_map.clear();

src/android/com/knowledgecode/cordova/websocket/ResetTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void execute(String rawArgs, CallbackContext ctx) {
4747
int key = _map.keyAt(i);
4848

4949
if (_map.get(key).isOpen()) {
50-
_map.get(key).close();
50+
_map.get(key).close(true);
5151
}
5252
}
5353
_map.clear();

src/android/org/eclipse/jetty/websocket/WebSocket.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ public interface Connection
123123
*/
124124
void close();
125125

126+
/**
127+
* Close the connection with normal close code.
128+
* @param silent Whether telling the app this thing or not
129+
*/
130+
void close(boolean silent);
131+
126132
/** Close the connection with specific closeCode and message.
127133
* @param closeCode The close code to send, or -1 for no close code
128134
* @param message The message to send or null for no message

src/android/org/eclipse/jetty/websocket/WebSocketConnectionRFC6455.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,16 @@ public void close()
609609
close(CLOSE_NORMAL,null);
610610
}
611611

612+
/* ------------------------------------------------------------ */
613+
public void close(boolean silent)
614+
{
615+
if (silent)
616+
{
617+
_closeCode = CLOSE_NORMAL;
618+
}
619+
close(CLOSE_NORMAL,null);
620+
}
621+
612622
/* ------------------------------------------------------------ */
613623
public void setAllowFrameFragmentation(boolean allowFragmentation)
614624
{

0 commit comments

Comments
 (0)