forked from ringcentral/pubnub-jtools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Devendra
committed
Jul 4, 2013
1 parent
6ef1e82
commit 1b5b802
Showing
40 changed files
with
640 additions
and
86 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file modified
BIN
+439 Bytes
(100%)
android/examples/PubnubExample/libs/Pubnub-Android-3.5.2.jar
Binary file not shown.
Binary file modified
BIN
+439 Bytes
(100%)
android/examples/SubscribeAtBoot/libs/Pubnub-Android-3.5.2.jar
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.codename1.io; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.Enumeration; | ||
import java.util.Hashtable; | ||
|
||
import com.codename1.impl.CodenameOneImplementation; | ||
import com.pubnub.api.HttpUtil; | ||
|
||
public class PubnubCn1Connection { | ||
|
||
private CodenameOneImplementation impl = Util.getImplementation(); | ||
private Object connection = null; | ||
private InputStream input = null; | ||
private byte[] data = null; | ||
|
||
public PubnubCn1Response fetch(String url, int timeout, Hashtable _headers) throws IOException { | ||
int rc = 0; | ||
String page = null; | ||
int contentLength = 0; | ||
|
||
while (HttpUtil.isRedirect(rc) || rc == 0) { | ||
connection = impl.connect(url, true, false, timeout); | ||
impl.setPostRequest(connection, false); | ||
|
||
if(_headers != null) { | ||
Enumeration e = _headers.keys(); | ||
while(e.hasMoreElements()) { | ||
String k = (String)e.nextElement(); | ||
String value = (String)_headers.get(k); | ||
impl.setHeader(connection, k, value); | ||
} | ||
} | ||
rc = impl.getResponseCode(connection); | ||
if(HttpUtil.isRedirect(rc)) { | ||
String uri = impl.getHeaderField("location", connection); | ||
if(!(uri.startsWith("http://") || uri.startsWith("https://"))) { | ||
url = Util.relativeToAbsolute(url, uri); | ||
} else { | ||
url = uri; | ||
} | ||
} | ||
} | ||
contentLength = impl.getContentLength(connection); | ||
input = impl.openInputStream(connection); | ||
data = Util.readInputStream(input); | ||
input.close(); | ||
input = null; | ||
return new PubnubCn1Response(rc, new String(data, "UTF-8")); | ||
} | ||
public void disconnect() { | ||
|
||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.codename1.io; | ||
|
||
public class PubnubCn1Response { | ||
private String response; | ||
private int responseStatusCode; | ||
public String getResponse() { | ||
return response; | ||
} | ||
public int getResponseStatusCode() { | ||
return responseStatusCode; | ||
} | ||
public PubnubCn1Response(int responseStatusCode, String response) { | ||
this.response = response; | ||
this.responseStatusCode = responseStatusCode; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.