Esempio n. 1
0
class AlexandriaXMPPClient(Client):
    
    def __init__(self, recipient, reply_callback):
        self.id = recipient
        self.reply_callback = reply_callback
        self.session_manager = SessionManager(client=self, backend=DBBackend())
        self.session_manager.restore()
    
    def send(self, message, end_of_session):
        self.reply_callback(self.id, message)
Esempio n. 2
0
class TestingClient(Client):
    
    def __init__(self, id):
        self.outbox = []
        self.id = id
        self.session_manager = SessionManager(client=self, backend=DBBackend())
        self.session_manager.restore()
     
    def send(self, message, end_of_session):
        self.outbox.append((message, end_of_session))
        if end_of_session:
            self.deactivate()
Esempio n. 3
0
class AlexandriaSSMIClient(Client):
    
    def __init__(self, msisdn, send_callback):
        self.id = msisdn
        self.session_manager = SessionManager(client=self, backend=DBBackend())
        self.session_manager.restore()
        self.send_callback = send_callback
    
    def send(self, text, end_session=False):
        if end_session:
            self.deactivate() # mark client as done
            reply_type = SSMI_USSD_TYPE_END
        else:
            reply_type = SSMI_USSD_TYPE_EXISTING
        return self.send_callback(self.id, text, reply_type)
Esempio n. 4
0
class VumiDBClient(Client):
    
    def __init__(self, msisdn, send_ussd_callback, send_sms_callback):
        self.id = msisdn
        self.session_manager = SessionManager(client=self, backend=DBBackend())
        self.session_manager.restore()
        self.send_ussd_callback = send_ussd_callback
        self.send_sms_callback = send_sms_callback
    
    def send(self, text, end_session=False):
        if end_session:
            reply_type = SessionType.end
        else:
            reply_type = SessionType.existing
        return self.send_ussd_callback(self.id, text, reply_type)
    
    def send_sms(self, text):
        return self.send_sms_callback(self.id, text)
Esempio n. 5
0
class StatefulClient(Client):
    """
    A client for Alexandria that stores its data in the in memory backend. The
    msisdn is used as a unique id to retrieve the client again from the 
    storage. The reply callback links back to the Consumer's reply instance
    which publishes to the queue.
    
    FIXME:  a publishing consumer? Confusing, this should be one PubSub class 
            and all this logic should be in the Worker class, not in the 
            consumer
    """
    def __init__(self, msisdn, reply_callback):
        self.id = msisdn
        self.reply_callback = reply_callback
        self.session_manager = SessionManager(client=self, backend=Backend())
        self.session_manager.restore()
    
    def send(self, message, end_of_session):
        if end_of_session:
            reply_type = SessionType.end
        else:
            reply_type = SessionType.existing
        self.reply_callback(self.id, message, reply_type)
Esempio n. 6
0
class DumbClient(Client):
    
    def __init__(self):
        self.id = "test_client"
        self.session_manager = SessionManager(client=self, backend=DBBackend())
        self.session_manager.restore()