Beispiel #1
0
    def process_message(self, content_type, message_head, content_length,
                        message_body):

        if content_type == 'auth/request':
            self.authenticate()
        if content_type == 'command/reply':
            if 'Reply-Text' in message_head:
                ldebug(
                    'FreeSWITCH command reply: %s' %
                    message_head['Reply-Text'], self)
        elif content_type == 'text/event-plain':
            event = to_hash(message_body.split(self.LINE_SEPARATOR))

            if 'Event-Name' in event and event[
                    'Event-Name'] in self.client_queues:
                event_type = event['Event-Name']
                for entry_id, message_pipe in self.client_queues[
                        event_type].items():
                    if type(message_pipe) == deque:
                        if len(message_pipe) < self.MESSAGE_PIPE_MAX_LENGTH:
                            message_pipe.appendleft({
                                'type': 'freeswitch_event',
                                'body': event
                            })
                        else:
                            lwarn("event queue %d full" % entry_id)
                    else:
                        ldebug(
                            "force-deregister event queue %d for event type %s"
                            % (entry_id, event_type), self)
                        del self.client_queues[event_type][entry_id]
Beispiel #2
0
 def deregister_handler_thread(self, handler_thread):
     if id(handler_thread) in self.handler_threads:
         ldebug('deregistering handler thread %d ' % id(handler_thread),
                self)
         del self.handler_threads[id(handler_thread)]
     else:
         lwarn('handler thread %d not registered' % id(handler_thread),
               self)
Beispiel #3
0
  def process_message(self, content_type, message_head, content_length, message_body):

    if content_type == 'auth/request':
      self.authenticate()
    if content_type == 'command/reply':
      if 'Reply-Text' in message_head:
        ldebug('FreeSWITCH command reply: %s' % message_head['Reply-Text'], self)
    elif content_type == 'text/event-plain':
      event = to_hash(message_body.split(self.LINE_SEPARATOR))
      
      if 'Event-Name' in event and event['Event-Name'] in self.client_queues:
        event_type = event['Event-Name']
        for entry_id, message_pipe in self.client_queues[event_type].items():
          if type(message_pipe) == deque:
            if len(message_pipe) < self.MESSAGE_PIPE_MAX_LENGTH:
              message_pipe.appendleft({'type': 'freeswitch_event', 'body': event})
            else:
              lwarn("event queue %d full" % entry_id)
          else:
            ldebug("force-deregister event queue %d for event type %s" % (entry_id, event_type), self)
            del self.client_queues[event_type][entry_id]
Beispiel #4
0
 def deregister_handler_thread(self, handler_thread):
     if id(handler_thread) in self.handler_threads:
         ldebug("deregistering handler thread %d " % id(handler_thread), self)
         del self.handler_threads[id(handler_thread)]
     else:
         lwarn("handler thread %d not registered" % id(handler_thread), self)
Beispiel #5
0
 def register_handler_thread(self, handler_thread):
     if handler_thread.isAlive():
         ldebug("registering handler thread %d " % id(handler_thread), self)
         self.handler_threads[id(handler_thread)] = handler_thread
     else:
         lwarn("handler thread passed away: %d" % id(handler_thread), self)
Beispiel #6
0
 def register_handler_thread(self, handler_thread):
     if handler_thread.isAlive():
         ldebug('registering handler thread %d ' % id(handler_thread), self)
         self.handler_threads[id(handler_thread)] = handler_thread
     else:
         lwarn('handler thread passed away: %d' % id(handler_thread), self)