2016-03-01 18:43:26 +02:00
|
|
|
#!/usr/bin/python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>
|
|
|
|
|
|
|
|
import threading
|
2016-03-23 17:15:27 +02:00
|
|
|
|
2016-03-01 18:43:26 +02:00
|
|
|
from base.Scope import Scope
|
|
|
|
|
2016-03-23 17:15:27 +02:00
|
|
|
|
2016-03-01 18:43:26 +02:00
|
|
|
class MessageResponseQueue(threading.Thread):
|
|
|
|
"""
|
|
|
|
This class handles responses and sends it to lider server.
|
|
|
|
"""
|
2016-03-23 17:15:27 +02:00
|
|
|
|
|
|
|
def __init__(self, outQueue):
|
2016-03-01 18:43:26 +02:00
|
|
|
super(MessageResponseQueue, self).__init__()
|
|
|
|
scope = Scope.getInstance()
|
|
|
|
self.logger = scope.getLogger()
|
2016-06-20 17:35:59 +03:00
|
|
|
self.messageManager = scope.getMessenger()
|
2016-03-01 18:43:26 +02:00
|
|
|
self.outQueue = outQueue
|
|
|
|
|
|
|
|
def run(self):
|
2016-03-23 17:15:27 +02:00
|
|
|
while True:
|
2016-03-30 10:43:38 +03:00
|
|
|
try:
|
|
|
|
# This item will send response to lider.
|
|
|
|
# item must be response message. Response message may be generic message type
|
|
|
|
responseMessage = self.outQueue.get(block=True)
|
|
|
|
self.logger.debug('[MessageResponseQueue] Sending response message to lider. Response Message ' + str(responseMessage))
|
|
|
|
# Call message manager for response
|
|
|
|
self.messageManager.send_direct_message(responseMessage)
|
|
|
|
# self.outQueue.task_done()
|
|
|
|
except Exception as e:
|
|
|
|
self.logger.error
|