Skip to content

Commit 088e3f2

Browse files
author
Devendra
committed
potential fix for java me build issue with codename1
1 parent 71dd52d commit 088e3f2

1 file changed

Lines changed: 40 additions & 26 deletions

File tree

‎java/srcPubnubApi/com/pubnub/api/PubnubCore.java‎

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,44 @@
1010
import java.util.Hashtable;
1111
import java.util.Random;
1212

13+
class EmptyResponseHandler extends ResponseHandler {
14+
15+
@Override
16+
public void handleResponse(HttpRequest hreq, String response) {
17+
18+
}
19+
20+
@Override
21+
public void handleError(HttpRequest hreq, PubnubError error) {
22+
23+
}
24+
25+
}
26+
27+
class PublishResponseHandler extends ResponseHandler {
28+
Callback callback;
29+
String channel;
30+
public PublishResponseHandler(Callback callback, String channel) {
31+
this.callback = callback;
32+
this.channel = channel;
33+
}
34+
public void handleResponse(HttpRequest hreq, String response) {
35+
JSONArray jsarr;
36+
try {
37+
jsarr = new JSONArray(response);
38+
} catch (JSONException e) {
39+
handleError(hreq,
40+
PubnubError.getErrorObject(PubnubError.PNERROBJ_INVALID_JSON, 1, response));
41+
return;
42+
}
43+
callback.successCallback(channel, jsarr);
44+
}
45+
46+
public void handleError(HttpRequest hreq, PubnubError error) {
47+
callback.errorCallback(channel, error);
48+
return;
49+
}
50+
}
1351

1452
/**
1553
* Pubnub object facilitates querying channels for messages and listening on
@@ -876,25 +914,8 @@ protected void publish(Hashtable args) {
876914
PubnubUtil.urlEncode(msgStr)
877915
};
878916

879-
class PublishResponseHandler extends ResponseHandler {
880-
public void handleResponse(HttpRequest hreq, String response) {
881-
JSONArray jsarr;
882-
try {
883-
jsarr = new JSONArray(response);
884-
} catch (JSONException e) {
885-
handleError(hreq,
886-
PubnubError.getErrorObject(PubnubError.PNERROBJ_INVALID_JSON, 1, response));
887-
return;
888-
}
889-
callback.successCallback(channel, jsarr);
890-
}
891917

892-
public void handleError(HttpRequest hreq, PubnubError error) {
893-
callback.errorCallback(channel, error);
894-
return;
895-
}
896-
}
897-
HttpRequest hreq = new HttpRequest(urlComponents, parameters, new PublishResponseHandler());
918+
HttpRequest hreq = new HttpRequest(urlComponents, parameters, new PublishResponseHandler(callback, channel));
898919

899920
_request(hreq, nonSubscribeManager);
900921
}
@@ -1759,14 +1780,7 @@ private void _leave(String channel, Hashtable params) {
17591780

17601781
params.put("uuid", UUID);
17611782

1762-
HttpRequest hreq = new HttpRequest(urlArgs, params,
1763-
new ResponseHandler() {
1764-
public void handleResponse(HttpRequest hreq, String response) {
1765-
}
1766-
1767-
public void handleError(HttpRequest hreq, PubnubError error) {
1768-
}
1769-
});
1783+
HttpRequest hreq = new HttpRequest(urlArgs, params, new EmptyResponseHandler());
17701784

17711785
_request(hreq, nonSubscribeManager);
17721786
}

0 commit comments

Comments
 (0)