forked from ringcentral/pubnub-jtools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServer.java
More file actions
41 lines (30 loc) · 1.17 KB
/
Server.java
File metadata and controls
41 lines (30 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package examples;
import java.util.HashMap;
import org.json.JSONArray;
import org.json.JSONObject;
import pubnub.Pubnub;
public class Server {
@SuppressWarnings("static-access")
public static void main(String [] params) {
Pubnub pn = new Pubnub( "demo", "demo", "demo", "", true ); //(Cipher key is Optional)
int count = 0;
while (true) {
count++;
System.out.print("sending message: " + count);
JSONObject message = new JSONObject();
try {
message.put( "some_val", "Hello World! --> ɂ顶@#$%^&*()!" + Integer.toString(count) );
}
catch (org.json.JSONException jsonError) {
System.out.println(jsonError);
}
HashMap<String, Object> args = new HashMap<String, Object>(2);
args.put("channel", "hello_world");
args.put("message", message);
JSONArray info = pn.publish( args );
System.out.println(", info: " + info);
try { Thread.currentThread().sleep(1000); }
catch ( Exception ex ) {}
}
}
}