Advertising the Pong feature of clients (Client DISCO)
One additional thing we should add to our XMPPong game is the ability for clients to discover it. Recall that a DISCO#info
request to the server will list the features that the room supports.
To do that, let’s but a handler in that recognizes when a DISCO
request is being sent:
socket.on('xmpp.discover.client', handleDisco)
You can place that right next to socket.on(‘xmpp.chat.message, handleMessage)
.
Now, we’ll implement the handleDisco
function, which will send the identity of this client and the features it supports:
function handleDisco(data) { socket.send( 'xmpp.discover.client', { to: data.from, id: data.id, features: [ { kind: 'identity', type: 'text', name: 'XMPPong', category: 'chat' }, { kind: 'feature', var: 'http://jabber.org/protocol/chat' } ] }, function(error, data) { console...