Exemple #1
0
    def process_msg(self, data):
        if (data['action'] == "register"):
            # adding fresh routingids to modemlist
            modemlist = []
            for modem in data['modemlist']:
                modem['routingid'] = str(uuid.uuid1())
                modemlist.append(modem)

            if WIS.register(modemlist):
                PID.addclientinfo(self.peer_address, data['pidid'],
                                  modemlist)

                data['status'] = "registered"
                # replace modemlist to have routingids in it
                data['modemlist'] = modemlist
                smsgwglobals.pislogger.debug("/ws: reply registered - " +
                                             str(data))
                # respond registation status
                PID.sendtopid(str(self.peer_address), data)
            else:
                closingreason = 'Unable to register to any WIS!'
                # tell PID to close and retry initialisation
                self.close(1011, closingreason)

        if data['action'] == "status":
            # set sms status to globals for handling in /sendsms
            PID.setclientsmsstatus(self.peer_address,
                                   data['smsid'],
                                   data['status'])

        if data['action'] == "heartbeat":
            # forward heartbeat to WIS
            httpcode = WIS.request_heartbeat(data)
            data['status'] = httpcode
            PID.sendtopid(str(self.peer_address), data)
Exemple #2
0
    def process_msg(self, data):
        if (data['action'] == "register"):
            # adding fresh routingids to modemlist
            modemlist = []
            for modem in data['modemlist']:
                modem['routingid'] = str(uuid.uuid1())
                modemlist.append(modem)

            if WIS.register(modemlist):
                PID.addclientinfo(self.peer_address, data['pidid'], modemlist)

                data['status'] = "registered"
                # replace modemlist to have routingids in it
                data['modemlist'] = modemlist
                smsgwglobals.pislogger.debug("/ws: reply registered - " +
                                             str(data))
                # respond registation status
                PID.sendtopid(str(self.peer_address), data)
            else:
                closingreason = 'Unable to register to any WIS!'
                # tell PID to close and retry initialisation
                self.close(1011, closingreason)

        if data['action'] == "status":
            # set sms status to globals for handling in /sendsms
            PID.setclientsmsstatus(self.peer_address, data['smsid'],
                                   data['status'], data['status_code'])

        if data['action'] == "heartbeat":
            # forward heartbeat to WIS
            httpcode = WIS.request_heartbeat(data)
            data['status'] = httpcode
            PID.sendtopid(str(self.peer_address), data)
Exemple #3
0
 def stop(self):
     # Unregister all Modems at WIS
     modemlist = PID.getclientmodemlist()
     PID.delclient()
     WIS.unregister(modemlist)
Exemple #4
0
 def closed(self, code, reason=None):
     modemlist = PID.getclientmodemlist(self.peer_address)
     PID.delclient(self.peer_address, code, reason)
     # Try to unregister
     WIS.unregister(modemlist)
Exemple #5
0
 def stop(self):
     # Unregister all Modems at WIS
     modemlist = PID.getclientmodemlist()
     PID.delclient()
     WIS.unregister(modemlist)
Exemple #6
0
 def closed(self, code, reason=None):
     modemlist = PID.getclientmodemlist(self.peer_address)
     PID.delclient(self.peer_address, code, reason)
     # Try to unregister
     WIS.unregister(modemlist)