Esempio n. 1
0
 def on_message(self, message):
     if message == '/count':
         self.write_message(
             'INFO|There are %d clients' % len(LastVisitsWebSocket.waiters))
     elif message == '/queue_count':
         self.write_message(
             'INFO|There are %d waiting messages' % MESSAGE_QUEUE.qsize())
     elif message == '/site':
         self.write_message(
             'INFO|You are on %s' % self.site)
Esempio n. 2
0
    def get(self, stamp):
        self.set_header("Content-Type", 'image/gif')
        gif_fn = os.path.join(
            self.application.settings['static_path'], 'pystil.gif')

        with open(gif_fn, 'rb') as gif_file:
            self.write(gif_file.read())
        self.finish()
        try:
            ua = self.request.headers.get('User-Agent')
        except KeyError:
            ua = 'Unknown'

        message = Message(
            self.log,
            self.request.arguments,
            ua,
            self.request.headers.get(
                'X-FORWARDED-FOR', self.request.remote_ip))
        self.log.debug('Inserting message for %s (Already in queue %s)' % (
            message.ip, MESSAGE_QUEUE.qsize()))
        MESSAGE_QUEUE.put(message, True)
        self.log.debug('Message for %s inserted' % message.ip)