update example code with new packet specific events

This commit is contained in:
Andrew Kelley 2013-01-02 21:59:40 -05:00
parent 796cb76435
commit fa1a8db52a
2 changed files with 2 additions and 4 deletions

View File

@ -38,8 +38,7 @@ var client = mc.createClient({
email: "email@example.com", // email and password are required only for
password: "12345678", // online-mode=true servers
});
client.on('packet', function(packet) {
if (packet.id !== 0x03) return;
client.on('packet-3', function(packet) {
if (packet.message.indexOf(client.session.username) !== -1) return;
client.writePacket(0x03, {
message: packet.message,

View File

@ -8,8 +8,7 @@ var client = mc.createClient({
client.on('connect', function() {
console.info("connected");
});
client.on('packet', function(packet) {
if (packet.id !== 0x03) return;
client.on('packet-3', function(packet) {
var match = packet.message.match(/^<(.+?)> (.*)$/);
if (! match) return;
var username = match[1];