Skip to content

Commit 3934992

Browse files
committed
add support for socket io queries.
fixes: koush#47
1 parent f40a0a5 commit 3934992

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

AndroidAsync/src/com/koushikdutta/async/http/socketio/SocketIOConnection.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,12 @@ protected void transform(String result) throws Exception {
122122
if (!set.contains("websocket"))
123123
throw new Exception("websocket not supported");
124124

125-
final String sessionUrl = request.getUri().toString() + "websocket/" + session + "/";
125+
String query;
126+
if (TextUtils.isEmpty(request.getQuery()))
127+
query = "?" + request.getQuery();
128+
else
129+
query = "";
130+
final String sessionUrl = request.getUri().toString() + "websocket/" + session + "/" + query;
126131

127132
httpClient.websocket(sessionUrl, null, null)
128133
.setCallback(getCompletionCallback());

AndroidAsync/src/com/koushikdutta/async/http/socketio/SocketIORequest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,18 @@ public String getEndpoint() {
1515
return endpoint;
1616
}
1717

18+
String query;
19+
public String getQuery() {
20+
return query;
21+
}
22+
1823
public SocketIORequest(String uri, String endpoint) {
24+
this(uri, endpoint, null);
25+
}
26+
27+
public SocketIORequest(String uri, String endpoint, String query) {
1928
super(Uri.parse(uri).buildUpon().encodedPath("/socket.io/1/").build().toString());
2029
this.endpoint = endpoint;
30+
this.query = query;
2131
}
2232
}

AndroidAsyncTest/src/com/koushikdutta/async/test/FutureTests.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -348,14 +348,7 @@ public void run() {
348348
assertEquals((int)results.get(i), i);
349349
}
350350
}
351-
352-
353-
class TriggerFuture extends SimpleFuture<Integer> {
354-
public void trigger() {
355-
setComplete(2020);
356-
}
357-
}
358-
351+
359352
public void testReentrancy() throws Exception {
360353
// verify reentrancy will work
361354

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.koushikdutta.async.test;
2+
3+
import com.koushikdutta.async.future.SimpleFuture;
4+
5+
class TriggerFuture extends SimpleFuture<Integer> {
6+
public void trigger() {
7+
setComplete(2020);
8+
}
9+
}

0 commit comments

Comments
 (0)