Guest User

Untitled

a guest
Jul 19th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. var net = require("net");
  2. var xmpp = require('node-xmpp');
  3.  
  4. var server = net.createServer(
  5. function(socket) {
  6.  
  7. socket.setEncoding("utf8");
  8. socket.on('data',function(data) {
  9. chat(data,socket);
  10. });
  11. }
  12. );
  13. server.listen(3000);
  14.  
  15. var chat = function(data,socket) {
  16. var cl = new xmpp.Client({ jid: 'admin@mine',password: '12345' });
  17.  
  18. cl.on('online',
  19. function() {
  20. cl.send(new xmpp.Element('message',
  21. { to: 'test@mine',
  22. type: 'chat'}).
  23. c('body').
  24. t(data));
  25.  
  26.  
  27. // nodejs has nothing left to do and will exit
  28. cl.end();
  29. });
  30. }
Add Comment
Please, Sign In to add comment