src/main/java/de/unixwork/im/Xmpp.java

Wed, 25 Dec 2024 21:49:48 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Wed, 25 Dec 2024 21:49:48 +0100
changeset 0
f3095cda599e
child 1
42d0d099492b
permissions
-rw-r--r--

add initial code with minimal working contact list and conversations

0
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 package de.unixwork.im;
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 import java.io.IOException;
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 import java.util.ArrayList;
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 import java.util.List;
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 import java.util.concurrent.BlockingQueue;
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 import java.util.concurrent.LinkedBlockingQueue;
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 import java.util.logging.Level;
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 import java.util.logging.Logger;
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 import org.jivesoftware.smack.ConnectionConfiguration;
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 import org.jivesoftware.smack.SmackException;
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 import org.jivesoftware.smack.XMPPException;
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 import org.jivesoftware.smack.filter.MessageWithBodiesFilter;
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 import org.jivesoftware.smack.packet.Message;
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 import org.jivesoftware.smack.packet.MessageBuilder;
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 import org.jivesoftware.smack.roster.Roster;
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 import org.jivesoftware.smack.roster.RosterEntry;
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 import org.jivesoftware.smack.tcp.XMPPTCPConnection;
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration;
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 import org.jxmpp.stringprep.XmppStringprepException;
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 public class Xmpp extends Thread {
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 private final XMPPTCPConnectionConfiguration config;
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 private XMPPTCPConnection connection = null;
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28 // BlockingQueue for event-driven communication
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 private final BlockingQueue<XmppEvent> eventQueue = new LinkedBlockingQueue<>();
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31 public Xmpp(XMPPTCPConnectionConfiguration xmppConfig) {
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32 config = xmppConfig;
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 }
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35 // Method to send a message (this will be called from another thread)
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 public void sendMessage(String to, String message, boolean encrypted) {
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37 try {
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38 XmppMessage event = new XmppMessage(to, message, encrypted);
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39 eventQueue.put(event); // Block if the queue is full
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40 } catch (InterruptedException e) {
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41 Logger.getLogger(Xmpp.class.getName()).log(Level.SEVERE, "Error adding event to queue", e);
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 }
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43 }
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45 private void connect() throws SmackException, IOException, XMPPException, InterruptedException {
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46 connection = new XMPPTCPConnection(config);
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47 connection.setUseStreamManagement(false);
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48 connection.connect();
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
49 connection.login();
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51 }
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
52
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53 public List<RosterEntry> getRosterItems() throws SmackException.NotLoggedInException, SmackException.NotConnectedException, InterruptedException {
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54 try {
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55 // Ensure we are connected
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
56 if (connection != null && connection.isConnected()) {
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
57 // Get the roster instance
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58 Roster roster = Roster.getInstanceFor(connection);
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60 // Fetch all roster entries (contacts)
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
61 roster.reload();
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
62
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
63 // Add all roster entries to the list
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
64 ArrayList<RosterEntry> rosterList = new ArrayList<>(16);
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
65 roster.getEntries().forEach(entry -> rosterList.add(entry));
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
66
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
67 // Optionally, print the list to verify
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
68 System.out.println("Roster List: ");
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
69 for (RosterEntry entry : rosterList) {
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
70 System.out.println("Contact: " + entry.getUser());
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
71 }
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
72
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
73 return rosterList;
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
74 } else {
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
75 System.out.println("Not connected to XMPP server.");
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
76 }
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
77 } catch (SmackException e) {
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
78 Logger.getLogger(Xmpp.class.getName()).log(Level.SEVERE, "Error getting roster items", e);
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
79 }
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
80
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
81 return null;
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
82 }
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
84 @Override
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
85 public void run() {
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
86 try {
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
87 connect();
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
88 connection.addAsyncStanzaListener((stanza -> {
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
89 var jid = stanza.getFrom();
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
90 if(jid != null) {
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
91 String body = ((Message)stanza).getBody();
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
92 App.getInstance().dispatchMessage(jid, body, true);
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
93 }
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
94 }), MessageWithBodiesFilter.INSTANCE);
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
95 List<RosterEntry> roster = getRosterItems();
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
96 if(roster != null) {
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
97 App.getInstance().setContacts(roster);
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
98 }
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
99
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
100 while (true) {
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
101 // Wait for an event (message to send)
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
102 XmppEvent event = eventQueue.take(); // This will block until an event is available
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
103 event.exec(this, connection);
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
104 }
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
105 } catch (SmackException ex) {
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
106 Logger.getLogger(Xmpp.class.getName()).log(Level.SEVERE, null, ex);
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
107 } catch (IOException ex) {
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
108 Logger.getLogger(Xmpp.class.getName()).log(Level.SEVERE, null, ex);
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
109 } catch (XMPPException ex) {
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
110 Logger.getLogger(Xmpp.class.getName()).log(Level.SEVERE, null, ex);
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
111 } catch (InterruptedException ex) {
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
112 Logger.getLogger(Xmpp.class.getName()).log(Level.SEVERE, null, ex);
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
113 }
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
114 }
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
115 }
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
116
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
117 class XmppMessage implements XmppEvent {
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
118 String to;
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
119 String message;
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
120 boolean encrypted;
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
121
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
122 XmppMessage(String to, String message, boolean encrypted) {
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
123 this.to = to;
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
124 this.message = message;
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
125 this.encrypted = encrypted;
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
126 }
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
127
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
128 public void exec(Xmpp xmpp, XMPPTCPConnection conn) {
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
129 final Message msg;
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
130 try {
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
131 msg = MessageBuilder.buildMessage()
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
132 .to(to)
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
133 .setBody(message)
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
134 .build();
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
135 conn.sendStanza(msg);
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
136 } catch (XmppStringprepException ex) {
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
137 Logger.getLogger(XmppMessage.class.getName()).log(Level.SEVERE, null, ex);
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
138 } catch (SmackException.NotConnectedException ex) {
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
139 Logger.getLogger(XmppMessage.class.getName()).log(Level.SEVERE, null, ex);
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
140 } catch (InterruptedException ex) {
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
141 Logger.getLogger(XmppMessage.class.getName()).log(Level.SEVERE, null, ex);
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
142 }
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
143 }
f3095cda599e add initial code with minimal working contact list and conversations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
144 }

mercurial