Cleanup the threading, its a method in openfiremanager now to spawn a threaded broadcast.

Also added date to the broadcast.
This commit is contained in:
Tyler274
2015-01-07 15:19:51 -05:00
parent d74ff5fc91
commit e386586fd0
2 changed files with 26 additions and 20 deletions

View File

@@ -10,11 +10,18 @@ from openfire import UserService
from authentication.managers import AuthServicesInfoManager
import threading
class OpenfireManager:
def __init__(self):
pass
@staticmethod
def send_broadcast_threaded(group_name, broadcast_message):
broadcast_thread = XmppThread(1, "XMPP Broadcast Thread", 1, group_name, broadcast_message)
broadcast_thread.start()
@staticmethod
def __add_address_to_username(username):
address = urlparse(settings.OPENFIRE_ADDRESS).netloc.split(":")[0]
@@ -118,4 +125,17 @@ class OpenfireManager:
client.send(message)
client.Process(1)
client.disconnect()
client.disconnect()
class XmppThread (threading.Thread):
def __init__(self, threadID, name, counter, group, message,):
threading.Thread.__init__(self)
self.threadID = threadID
self.name = name
self.counter = counter
self.group = group
self.message = message
def run(self):
print "Starting " + self.name
OpenfireManager.send_broadcast_message(self.group, self.message)
print "Exiting " + self.name