Login
The first task we'll need to complete is to get logged in to our server. Let's create a script file in our project at public/scripts/xmpp.js
, where we can start handling the client side features. To handle login, we'll listen for a client on the login button:
socket.on('xmpp.connection', connected) var connected = function(details) { $('p.connection-status').html('Online') } socket.on('xmpp.error', errorReceived) var errorReceived = function(error) { if ('auth' === error.type) { return alert('Authentication failed') } } $('button[name="login"]').click(function() { var jid = $('input[name="jid"]').val() var password = $('input[name="password"]').val() if (!jid || !password) { return alert('Please enter connection details') } var options = { jid: jid, password: password } socket.send('xmpp.login', options) })
Once you've completed this...