1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.xnap.plugin.joscar.msg;
21
22 import org.apache.log4j.Logger;
23
24 import JOscarLib.Core.OscarConnection;
25
26 /***
27 *
28 */
29 public class JOscarMessageSender implements Runnable
30 {
31
32
33
34
35 private boolean die = false;
36 private JOscarMessageQueue queue;
37 private OscarConnection connection;
38 private Thread t = null;
39
40 private static Logger logger = Logger.getLogger(JOscarMessageQueue.class);
41
42
43
44 public JOscarMessageSender(JOscarMessageQueue queue)
45
46 {
47 this.queue = queue;
48 }
49
50
51
52 public void setConnection(OscarConnection connection)
53 {
54 this.connection = connection;
55 }
56
57 public void start()
58 {
59 die = false;
60 t = new Thread(this, "JOscarMessageSender");
61 t.start();
62 }
63
64 public void stop()
65 {
66 die = true;
67 if (t != null) {
68 t.interrupt();
69 }
70 }
71
72 public void run()
73 {
74 while (!die) {
75 JOscarMessage msg = null;
76 try {
77 msg = queue.getMessage();
78 }
79 catch (InterruptedException ie) {
80 continue;
81 }
82 msg.send(connection);
83 }
84 }
85 }