socketHandler.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. 'use strict';
  2. module.exports = (core, io) => {
  3. io.on('connection', socket => {
  4. console.log("User has connected");
  5. let _user = socket.request.user;
  6. socket.on('disconnect', () => {
  7. console.log('User has disconnected');
  8. });
  9. socket.on('/users/register', (username, email, password, recaptcha, cb) => {
  10. core['/users/register'](result => {
  11. cb(result);
  12. });
  13. });
  14. socket.on('/stations', cb => {
  15. core['/stations'](result => {
  16. cb(result);
  17. });
  18. });
  19. /*socket.on('/station/:id/join', (id, cb) => {
  20. console.log("JOINED!!!");
  21. core['/station/:id/join'](id, socket.id, result => {
  22. console.log("CALLBACK!!!");
  23. cb(result);
  24. });
  25. });*/
  26. socket.on('/youtube/getVideos/:query', (query, cb) => {
  27. core['/youtube/getVideos/:query'](query, result => {
  28. cb(result);
  29. });
  30. });
  31. socket.on('/songs/queue/addSongs/:songs', (songs, cb) => {
  32. core['/songs/queue/addSongs/:songs'](songs, _user, result => {
  33. cb(result);
  34. });
  35. });
  36. socket.on('/songs/queue/getSongs', (cb) => {
  37. core['/songs/queue/getSongs'](_user, result => {
  38. cb(result);
  39. });
  40. });
  41. socket.on('/songs/queue/updateSong/:id', (id, object, cb) => {
  42. core['/songs/queue/updateSong/:id'](_user, id, object, result => {
  43. cb(result);
  44. });
  45. });
  46. /*socket.on('/stations/search/:query', (query, cb) => {
  47. core['/stations/search/:query'](query, result => {
  48. cb(result);
  49. });
  50. });*/
  51. // this lets the client socket know that they can start making request
  52. //socket.emit('ready', user.logged_in);
  53. });
  54. };