This repository was archived by the owner on May 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBaseSample.java
More file actions
56 lines (38 loc) · 1.35 KB
/
BaseSample.java
File metadata and controls
56 lines (38 loc) · 1.35 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package samples;
import com.rayo.client.RayoClient;
import com.rayo.client.listener.StanzaListener;
import com.rayo.client.xmpp.stanza.Error;
import com.rayo.client.xmpp.stanza.IQ;
import com.rayo.client.xmpp.stanza.Message;
import com.rayo.client.xmpp.stanza.Presence;
public abstract class BaseSample {
protected RayoClient client;
public void connect(String xmppServer, String username, String password, String rayoServer) throws Exception {
client = new RayoClient(xmppServer, rayoServer);
login(username,password,"voxeo");
}
public void shutdown() throws Exception {
client.disconnect();
}
void login(String username, String password, String resource) throws Exception {
client.connect(username, password, resource);
client.addStanzaListener(new StanzaListener() {
@Override
public void onPresence(Presence presence) {
//System.out.println(String.format("Message from server: [%s]",presence));
}
@Override
public void onMessage(Message message) {
//System.out.println(String.format("Message from server: [%s]",message));
}
@Override
public void onIQ(IQ iq) {
//System.out.println(String.format("Message from server: [%s]",iq));
}
@Override
public void onError(Error error) {
//System.out.println(String.format("Message from server: [%s]",error));
}
});
}
}