When a new message arrives, it publishes to all listening clients.

def on_message(self, websocket, msg):
        '''When a new message arrives, it publishes to all listening clients.
        '''
        if msg:
            lines = []
            for li in msg.split('\n'):
                li = li.strip()
                if li:
                    lines.append(li)
            msg = ' '.join(lines)
            if msg:
                return self.pubsub.publish(self.channel, msg)