'use strict'

var Client = require('node-xmpp-client')

// connect using the admin user's creds
var client = new Client({jid: 'admin@some.server.org', password: '1234'})

// check for errors on the socket
client.connection.socket.on('error', function (error) {
  console.error(error)
  process.exit(1)
})


client.on('online', function (data) {
  // stanza to be sent to the server
  var stanza = new Client.Stanza('iq', { type:'set', id:'reg1', to:'some.server.org' })
   .c('query',{ xmlns: 'jabber:iq:register'})
   .c('username').t('user').up()  // Give a username
   .c('password').t('1234')  // Give a password
  client.send(stanza) // send a stanza

})

// response stanzas
client.on('stanza', function (stanza) {
  if (stanza.attrs.type === 'error') {
   console.log('[error] ' + stanza);
   return;
  }
  /*
  For ejabberd users:
    If you get error code 403
    change {access, register} to {access_from, register}
    and
    comment out the ip_access section in your ejabberdctl.cfg
  */
})

client.on('error', function (err) {
  console.error(err)
  process.exit(1)
})
@@ -299,17 +299,16 @@
 (1)%0A%7D)%0A%0A
-%0A
 client.o
@@ -418,14 +418,14 @@
 ', %7B
- 
 type:
+ 
 'set
@@ -430,16 +430,17 @@
 et', id:
+ 
 'reg1', 
@@ -442,16 +442,17 @@
 g1', to:
+ 
 'some.se
@@ -460,17 +460,16 @@
 ver.org'
- 
 %7D)%0A   .c
@@ -481,10 +481,10 @@
 ry',
-%7B
  
+%7B
 xmln
@@ -649,17 +649,16 @@
  stanza%0A
-%0A
 %7D)%0A%0A// r
@@ -755,16 +755,17 @@
 ') %7B%0A   
+ 
 console.
@@ -788,18 +788,18 @@
  stanza)
-;
 %0A
+ 
    retur
@@ -803,9 +803,8 @@
 turn
-;
 %0A  %7D
@@ -1052,30 +1052,31 @@
 rror(err)%0A  process.exit(1)%0A
-
 %7D)
+%0A

fix in-bang registration example code style