def _handle_newstate_ringing(self, event, destination):
        print "handle_newstate_ringing"
        channel = event[Asterisk11.HEADER_CHANNEL]

        if channel == None:
            return None

        message = ChannelMessage()

        message.set_event(ChannelMessage.EVENT_RINGING)
        message.set_id(event[Asterisk11.HEADER_UNIQUEID])

        try:
            parent_event = AsteriskEvent.selectBy(event = Asterisk11.EVENT_DIAL, uniqueid = event[Asterisk11.HEADER_UNIQUEID])[0]
        except Exception as e:
            print e
            parent_event = None

        if parent_event != None:
            raw = eval(parent_event.raw)
        else:
            raw = None

        if raw != None:
            caller = raw[Asterisk11.HEADER_CALLERIDNUM]
            extension = event[Asterisk11.HEADER_CALLERIDNUM]
        else:
            caller = AsteriskCommandHandler.CALLERID_UNKNOWN
            extension = AsteriskCommandHandler.CALLERID_UNKNOWN

        message.set_extension(extension)
        message.set_caller(caller)

        send_message(destination, message.dump_data_json(), get_local_number(channel))
    def _handle_newstate_ringing(self, event, destination):
        print "handle_newstate_ringing"
        channel = event[Asterisk11.HEADER_CHANNEL]

        if channel == None:
            return None

        message = ChannelMessage()

        message.set_event(ChannelMessage.EVENT_RINGING)
        message.set_id(event[Asterisk11.HEADER_UNIQUEID])

        try:
            parent_event = AsteriskEvent.selectBy(event = Asterisk11.EVENT_DIAL, uniqueid = event[Asterisk11.HEADER_UNIQUEID])[0]
        except Exception as e:
            print e
            parent_event = None

        if parent_event != None:
            raw = eval(parent_event.raw)
        else:
            raw = None

        if raw != None:
            caller = raw[Asterisk11.HEADER_CALLERIDNUM]
            extension = event[Asterisk11.HEADER_CALLERIDNUM]
        else:
            caller = AsteriskCommandHandler.CALLERID_UNKNOWN
            extension = AsteriskCommandHandler.CALLERID_UNKNOWN

        message.set_extension(extension)
        message.set_caller(caller)

        send_message(destination, message.dump_data_json(), get_local_number(channel))
    def handle_Bridge(self, event, manager):
        """
        Event: Bridge
        Privilege: call,all
        Bridgestate: Link
        Bridgetype: core
        Channel1: SIP/101-00000058
        Channel2: SIP/104-00000059
        Uniqueid1: 1309443548.88
        Uniqueid2: 1309443548.89
        CallerID1: 101
        CallerID2: 104

        {'Uniqueid2': '1309506586.133', 'Uniqueid1': '1309506586.132', 'CallerID2': '104', 'Bridgestate': 'Link', 'CallerID1': '101', 'Channel2': 'SIP/104-00000085', 'Channel1': 'SIP/101-00000084', 'Bridgetype': 'core', 'Privilege': 'call,all', 'Event': 'Bridge'}

        """

        message = ChannelMessage()

        message.set_event(ChannelMessage.EVENT_LINK)
        message.set_id(event[Asterisk11.HEADER_UNIQUEID2])
        message.set_extension(event[Asterisk11.HEADER_CALLERID2])
        message.set_caller(event[Asterisk11.HEADER_CALLERID1])

        send_message(manager.destination, message.dump_data_json(), get_local_number(event[Asterisk11.HEADER_CHANNEL2]))
    def handle_Bridge(self, event, manager):
        """
        Event: Bridge
        Privilege: call,all
        Bridgestate: Link
        Bridgetype: core
        Channel1: SIP/101-00000058
        Channel2: SIP/104-00000059
        Uniqueid1: 1309443548.88
        Uniqueid2: 1309443548.89
        CallerID1: 101
        CallerID2: 104

        {'Uniqueid2': '1309506586.133', 'Uniqueid1': '1309506586.132', 'CallerID2': '104', 'Bridgestate': 'Link', 'CallerID1': '101', 'Channel2': 'SIP/104-00000085', 'Channel1': 'SIP/101-00000084', 'Bridgetype': 'core', 'Privilege': 'call,all', 'Event': 'Bridge'}

        """

        message = ChannelMessage()

        message.set_event(ChannelMessage.EVENT_LINK)
        message.set_id(event[Asterisk11.HEADER_UNIQUEID2])
        message.set_extension(event[Asterisk11.HEADER_CALLERID2])
        message.set_caller(event[Asterisk11.HEADER_CALLERID1])

        send_message(manager.destination, message.dump_data_json(), get_local_number(event[Asterisk11.HEADER_CHANNEL2]))
Example #5
0
    def handle_QueueMemberPaused(self, event, manager):
        location = event[Asterisk.HEADER_LOCATION]

        if location == None:
            return None

        message = ChannelMessage()
        message.set_event(ChannelMessage.EVENT_QUEUE_MEMBER_PAUSED)
        send_message(manager.destination, message.dump_data_json(), get_local_number(location))
Example #6
0
    def handle_QueueMemberPaused(self, event, manager):
        location = event[Asterisk.HEADER_LOCATION]

        if location == None:
            return None

        message = ChannelMessage()
        message.set_event(ChannelMessage.EVENT_QUEUE_MEMBER_PAUSED)
        send_message(manager.destination, message.dump_data_json(),
                     get_local_number(location))
    def _handle_hangup_clearing(self, event, destination):
        channel = event[Asterisk10.HEADER_CHANNEL]

        if channel == None:
            return None

        message = ChannelMessage()

        message.set_event(ChannelMessage.EVENT_HANGUP_CLEANUP)
        message.set_id(event[Asterisk10.HEADER_UNIQUEID])

        send_message(destination, message.dump_data_json(), get_local_number(channel))
    def handle_Link(self, event, manager):
        """
        {'Uniqueid2': '1306914758.6999', 'Uniqueid1': '1306914726.6994', 'Channel1': 'SIP/430913-19be0080', 'Channel2': 'SIP/1313-19ba26d0', 'CallerID2': '380352407040', 'Privilege': 'call,all', 'CallerID1': '430913', 'Event': 'Link'}
        """

        message = ChannelMessage()

        message.set_event(ChannelMessage.EVENT_LINK)
        message.set_id(event[Asterisk10.HEADER_UNIQUEID1])
        message.set_extension(event[Asterisk10.HEADER_CALLERID1])
        message.set_caller(event[Asterisk10.HEADER_CALLERID2])

        send_message(manager.destination, message.dump_data_json(), get_local_number(event[Asterisk10.HEADER_CHANNEL1]))
    def _handle_hangup_clearing(self, event, destination):
        print "handle_hangup_clearing"
        channel = event[Asterisk11.HEADER_CHANNEL]

        if channel == None:
            return None

        message = ChannelMessage()

        message.set_event(ChannelMessage.EVENT_HANGUP_CLEANUP)
        message.set_id(event[Asterisk11.HEADER_UNIQUEID])

        send_message(destination, message.dump_data_json(), get_local_number(channel))
    def handle_Link(self, event, manager):
        """
        {'Uniqueid2': '1306914758.6999', 'Uniqueid1': '1306914726.6994', 'Channel1': 'SIP/430913-19be0080', 'Channel2': 'SIP/1313-19ba26d0', 'CallerID2': '380352407040', 'Privilege': 'call,all', 'CallerID1': '430913', 'Event': 'Link'}
        """

        message = ChannelMessage()

        message.set_event(ChannelMessage.EVENT_LINK)
        message.set_id(event[Asterisk10.HEADER_UNIQUEID1])
        message.set_extension(event[Asterisk10.HEADER_CALLERID1])
        message.set_caller(event[Asterisk10.HEADER_CALLERID2])

        send_message(manager.destination, message.dump_data_json(),
                     get_local_number(event[Asterisk10.HEADER_CHANNEL1]))
Example #11
0
    def _handle_newstate_ringing(self, event, destination):
        #Newstate {
        # 'ConnectedLineNum': '102',
        # 'ChannelState': '5',
        # 'CallerIDNum': '',
        # 'ConnectedLineName': '',
        # 'Uniqueid': '1330721579.25',
        # 'CallerIDName': '',
        # 'Privilege': 'call,all',
        # 'Event': 'Newstate',
        # 'Channel': 'SIP/101-00000019',
        # 'ChannelStateDesc': 'Ringing'}

        channel = event[Asterisk11.HEADER_CHANNEL]

        if channel == None:
            return None

        message = ChannelMessage()

        message.set_event(ChannelMessage.EVENT_RINGING)
        message.set_id(event[Asterisk11.HEADER_UNIQUEID])
#
#        try:
#            parent_event = AsteriskEvent.selectBy(event = Asterisk11.EVENT_DIAL, uniqueid = event[Asterisk11.HEADER_UNIQUEID])[0]
#        except Exception as e:
#            print e
#            parent_event = None
#
#        if parent_event != None:
#            raw = eval(parent_event.raw)
#        else:
#            raw = None
#
#        if raw != None:
#            caller = raw[Asterisk11.HEADER_CALLERIDNUM]
#            extension = event[Asterisk11.HEADER_CALLERIDNUM]
#        else:
#            caller = AsteriskCommandHandler.CALLERID_UNKNOWN
#            extension = AsteriskCommandHandler.CALLERID_UNKNOWN
#
#        message.set_extension(extension)
#        message.set_caller(caller)

#        queue name??? or extension???
#        caller number???

        send_message(destination, message.dump_data_json(), get_local_number(channel))