-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
saving timetoken on new susbcribe, and added logic to calculate timet…
…oken when RESUME on reconnect is enabled
- Loading branch information
Devendra
committed
Feb 4, 2013
1 parent
82633ea
commit 19f5196
Showing
5 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
Binary file not shown.
74 changes: 74 additions & 0 deletions
74
java/3.4/examples/src/com/pubnub/examples/PubnubTestClient.java
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,74 @@ | |||
package com.pubnub.examples; | |||
|
|||
import java.util.Hashtable; | |||
|
|||
import com.pubnub.api.Callback; | |||
import com.pubnub.api.Pubnub; | |||
|
|||
public class PubnubTestClient { | |||
Pubnub pubnub; | |||
int recvSuccess; | |||
int recvErrors; | |||
int sendSuccess; | |||
int sendErrors; | |||
|
|||
PubnubTestClient() { | |||
pubnub = new Pubnub("demo", "demo", "demo", false); | |||
} | |||
|
|||
public void runTest() { | |||
Hashtable args = new Hashtable(); | |||
args.put("channel", "TestClientChannel"); | |||
try { | |||
pubnub.subscribe(args, new Callback() { | |||
|
|||
public void successCallback(String channel, Object message) { | |||
recvSuccess++; | |||
} | |||
public void errorCallback(String channel, Object message) { | |||
recvErrors++; | |||
} | |||
}); | |||
|
|||
} catch (Exception e) { | |||
|
|||
} | |||
Callback publishCb = new Callback() { | |||
public void successCallback(String channel, Object message) { | |||
sendSuccess++; | |||
} | |||
|
|||
public void errorCallback(String channel, Object message) { | |||
System.out.println(message.toString()); | |||
sendErrors++; | |||
} | |||
}; | |||
args.put("message", "Test Client Message"); | |||
for (int i = 0; i < 10; i++) { | |||
pubnub.publish(args, publishCb); | |||
try { | |||
Thread.sleep(100); | |||
} catch (InterruptedException e) { | |||
e.printStackTrace(); | |||
} | |||
System.out.println("Send Success : " + sendSuccess ); | |||
System.out.println("Send Errors : " + sendErrors ); | |||
System.out.println("Receive Success : " + recvSuccess ); | |||
System.out.println("Receive Errors : " + recvErrors ); | |||
} | |||
System.out.println("Send Success : " + sendSuccess ); | |||
System.out.println("Send Errors : " + sendErrors ); | |||
System.out.println("Receive Success : " + recvSuccess ); | |||
System.out.println("Receive Errors : " + recvErrors ); | |||
|
|||
} | |||
|
|||
/** | |||
* @param args | |||
*/ | |||
public static void main(String[] args) { | |||
new PubnubTestClient().runTest(); | |||
|
|||
} | |||
|
|||
} |
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