var self = this;
socket.onmessage = function (e) {
channel.messages.push(JSON.parse(e.data));
if ( channel !== self.current ) { channel.unread++ }
};
l;
channel.unread = 0;
},
send: function() {
this.current.socket.send(JSON.stringify({username: this.username, message: this.message}));
this.message = '';
},
t.
An example is given in the distribution for using this class with L<Mojo::Pg::PubSub> to relay JSON messages between web-based chat clients.
As this module is low level it does no character encodi