Advertisement
Slowstone72

TMPPSFMS.txt

Dec 20th, 2024
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 1.74 KB | Software | 0 0
  1. /* Ancient code published for archival purposes. May or may not work or be relevant.
  2. Feel free to do whatever you want with this, if anything.
  3. Archive from 2017-10-07 - contents may be older. */
  4.  
  5. //The MultiplayerPiano.com Super Fast Messaging System
  6.  
  7.  
  8. clientWebsite = 'multiplayerpiano.com';
  9. clientWebsitePort = '8080';
  10. clientWebsocket = 'ws://' + clientWebsite + ':' + clientWebsitePort;
  11.  
  12. prefix = '/';
  13. rooms = [];
  14. clients = {};
  15. clientsconnected = false;
  16.  
  17. MPP.client.on("ls",function(ls){
  18. if(!clientsconnected)
  19. for(var room in ls.u){
  20. rooms.push(ls.u[room]._id);
  21. uniqueNames = [];
  22. $.each(rooms, function(i, el){
  23.     if($.inArray(el, rooms2) === -1) rooms2.push(el);
  24. });
  25.  
  26. };
  27. });
  28.  
  29. //MPP.chat.send('[The MultiplayerPiano.com Super Fast Messaging System]');
  30. //MPP.chat.send('The current prefix: ' + prefix + '. Use ' + prefix + 'help for the system\'s command list.');
  31. rooms2 = [];
  32. function connectClients() {
  33. i = -1;
  34. test = setInterval(function() {
  35. i++;
  36. clients[i] = new Client(clientWebsocket);
  37. clients[i].start();
  38. clients[i].setChannel(rooms2[i]);
  39. clients[i].on("a", function(msg) { if(msg.a.toLowerCase()==prefix+'help') {clients[i].sendArray([{m:"a", message: 'test' }]);} });
  40. if(i==rooms2.length) {clearInterval(test);console.log('Clients Connected'); }
  41. }, 500);}
  42.  
  43. function sendmessage(recipient,msg,sender) {
  44. for (var i = 0; i < Object.keys(clients).length; i++) {
  45. if(Object.values(clients[i].ppl).map(x => x._id)
  46.  
  47. .includes(recipient)){
  48. clients[i].sendArray([{m:"a", message: 'Notification: ' + JSON.stringify(clients[i].ppl).split(recipient)[1].split('"color"')[0].split('","name":')[1]
  49.  
  50.  + ' you have received a message from test' }]);
  51. clients[i].sendArray([{m:"a", message: '"' + msg + '"' }]);
  52. }
  53. else
  54. {
  55.  
  56. }
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement