Browse Source

Moved socket.io functions to the io module

Kristian Vos 4 years ago
parent
commit
18a33b69af

+ 4 - 2
backend/logic/actions/activities.js

@@ -2,8 +2,10 @@ import async from "async";
 
 import { isLoginRequired } from "./hooks";
 
-import DBModule from "../db";
-import UtilsModule from "../utils";
+import moduleManager from "../../index";
+
+const DBModule = moduleManager.modules.db;
+const UtilsModule = moduleManager.modules.utils;
 
 export default {
 	/**

+ 6 - 4
backend/logic/actions/apis.js

@@ -3,9 +3,11 @@ import async from "async";
 import request from "request";
 
 import { isAdminRequired } from "./hooks";
-// const moduleManager = require("../../index");
 
-import UtilsModule from "../utils";
+import moduleManager from "../../index";
+
+const UtilsModule = moduleManager.modules.utils;
+const IOModule = moduleManager.modules.io;
 
 export default {
 	/**
@@ -117,7 +119,7 @@ export default {
 	 */
 	joinRoom: (session, page, cb) => {
 		if (page === "home") {
-			UtilsModule.runJob("SOCKET_JOIN_ROOM", {
+			IOModule.runJob("SOCKET_JOIN_ROOM", {
 				socketId: session.socketId,
 				room: page
 			})
@@ -147,7 +149,7 @@ export default {
 			page === "statistics" ||
 			page === "punishments"
 		) {
-			UtilsModule.runJob("SOCKET_JOIN_ROOM", {
+			IOModule.runJob("SOCKET_JOIN_ROOM", {
 				socketId: session.socketId,
 				room: `admin.${page}`
 			});

+ 5 - 3
backend/logic/actions/hooks/adminRequired.js

@@ -1,8 +1,10 @@
 import async from "async";
 
-import DBModule from "../../db";
-import CacheModule from "../../cache";
-import UtilsModule from "../../utils";
+import moduleManager from "../../../index";
+
+const DBModule = moduleManager.modules.db;
+const CacheModule = moduleManager.modules.cache;
+const UtilsModule = moduleManager.modules.utils;
 
 export default destination => async (session, ...args) => {
 	const userModel = await DBModule.runJob("GET_MODEL", { modelName: "user" });

+ 4 - 2
backend/logic/actions/hooks/loginRequired.js

@@ -1,7 +1,9 @@
 import async from "async";
 
-import CacheModule from "../../cache";
-import UtilsModule from "../../utils";
+import moduleManager from "../../../index";
+
+const CacheModule = moduleManager.modules.cache;
+const UtilsModule = moduleManager.modules.utils;
 
 export default destination => (session, ...args) => {
 	const cb = args[args.length - 1];

+ 6 - 4
backend/logic/actions/hooks/ownerRequired.js

@@ -1,9 +1,11 @@
 import async from "async";
 
-import DBModule from "../../db";
-import CacheModule from "../../cache";
-import UtilsModule from "../../utils";
-import StationsModule from "../../stations";
+import moduleManager from "../../../index";
+
+const DBModule = moduleManager.modules.db;
+const CacheModule = moduleManager.modules.cache;
+const UtilsModule = moduleManager.modules.utils;
+const StationsModule = moduleManager.modules.stations;
 
 export default destination => async (session, stationId, ...args) => {
 	const userModel = await DBModule.runJob("GET_MODEL", { modelName: "user" });

+ 9 - 6
backend/logic/actions/news.js

@@ -2,14 +2,17 @@ import async from "async";
 
 import { isAdminRequired } from "./hooks";
 
-import DBModule from "../db";
-import UtilsModule from "../utils";
-import CacheModule from "../cache";
+import moduleManager from "../../index";
+
+const DBModule = moduleManager.modules.db;
+const UtilsModule = moduleManager.modules.utils;
+const IOModule = moduleManager.modules.io;
+const CacheModule = moduleManager.modules.cache;
 
 CacheModule.runJob("SUB", {
 	channel: "news.create",
 	cb: news => {
-		UtilsModule.runJob("EMIT_TO_ROOM", {
+		IOModule.runJob("EMIT_TO_ROOM", {
 			room: "admin.news",
 			args: ["event:admin.news.created", news]
 		});
@@ -19,7 +22,7 @@ CacheModule.runJob("SUB", {
 CacheModule.runJob("SUB", {
 	channel: "news.remove",
 	cb: news => {
-		UtilsModule.runJob("EMIT_TO_ROOM", {
+		IOModule.runJob("EMIT_TO_ROOM", {
 			room: "admin.news",
 			args: ["event:admin.news.removed", news]
 		});
@@ -29,7 +32,7 @@ CacheModule.runJob("SUB", {
 CacheModule.runJob("SUB", {
 	channel: "news.update",
 	cb: news => {
-		UtilsModule.runJob("EMIT_TO_ROOM", {
+		IOModule.runJob("EMIT_TO_ROOM", {
 			room: "admin.news",
 			args: ["event:admin.news.updated", news]
 		});

+ 15 - 14
backend/logic/actions/playlists.js

@@ -4,18 +4,19 @@ import { isLoginRequired } from "./hooks";
 
 import moduleManager from "../../index";
 
-import DBModule from "../db";
-import UtilsModule from "../utils";
-import SongsModule from "../songs";
-import CacheModule from "../cache";
-import PlaylistsModule from "../playlists";
-import YouTubeModule from "../youtube";
-import ActivitiesModule from "../activities";
+const DBModule = moduleManager.modules.db;
+const UtilsModule = moduleManager.modules.utils;
+const IOModule = moduleManager.modules.io;
+const SongsModule = moduleManager.modules.songs;
+const CacheModule = moduleManager.modules.cache;
+const PlaylistsModule = moduleManager.modules.playlists;
+const YouTubeModule = moduleManager.modules.youtube;
+const ActivitiesModule = moduleManager.modules.activities;
 
 CacheModule.runJob("SUB", {
 	channel: "playlist.create",
 	cb: playlist => {
-		UtilsModule.runJob("SOCKETS_FROM_USER", { userId: playlist.createdBy }).then(response => {
+		IOModule.runJob("SOCKETS_FROM_USER", { userId: playlist.createdBy }).then(response => {
 			response.sockets.forEach(socket => {
 				socket.emit("event:playlist.create", playlist);
 			});
@@ -26,7 +27,7 @@ CacheModule.runJob("SUB", {
 CacheModule.runJob("SUB", {
 	channel: "playlist.delete",
 	cb: res => {
-		UtilsModule.runJob("SOCKETS_FROM_USER", { userId: res.userId }).then(response => {
+		IOModule.runJob("SOCKETS_FROM_USER", { userId: res.userId }).then(response => {
 			response.sockets.forEach(socket => {
 				socket.emit("event:playlist.delete", res.playlistId);
 			});
@@ -37,7 +38,7 @@ CacheModule.runJob("SUB", {
 CacheModule.runJob("SUB", {
 	channel: "playlist.moveSongToTop",
 	cb: res => {
-		UtilsModule.runJob("SOCKETS_FROM_USER", { userId: res.userId }).then(response => {
+		IOModule.runJob("SOCKETS_FROM_USER", { userId: res.userId }).then(response => {
 			response.sockets.forEach(socket => {
 				socket.emit("event:playlist.moveSongToTop", {
 					playlistId: res.playlistId,
@@ -51,7 +52,7 @@ CacheModule.runJob("SUB", {
 CacheModule.runJob("SUB", {
 	channel: "playlist.moveSongToBottom",
 	cb: res => {
-		UtilsModule.runJob("SOCKETS_FROM_USER", { userId: res.userId }).then(response => {
+		IOModule.runJob("SOCKETS_FROM_USER", { userId: res.userId }).then(response => {
 			response.sockets.forEach(socket => {
 				socket.emit("event:playlist.moveSongToBottom", {
 					playlistId: res.playlistId,
@@ -65,7 +66,7 @@ CacheModule.runJob("SUB", {
 CacheModule.runJob("SUB", {
 	channel: "playlist.addSong",
 	cb: res => {
-		UtilsModule.runJob("SOCKETS_FROM_USER", { userId: res.userId }).then(response => {
+		IOModule.runJob("SOCKETS_FROM_USER", { userId: res.userId }).then(response => {
 			response.sockets.forEach(socket => {
 				socket.emit("event:playlist.addSong", {
 					playlistId: res.playlistId,
@@ -79,7 +80,7 @@ CacheModule.runJob("SUB", {
 CacheModule.runJob("SUB", {
 	channel: "playlist.removeSong",
 	cb: res => {
-		UtilsModule.runJob("SOCKETS_FROM_USER", { userId: res.userId }).then(response => {
+		IOModule.runJob("SOCKETS_FROM_USER", { userId: res.userId }).then(response => {
 			response.sockets.forEach(socket => {
 				socket.emit("event:playlist.removeSong", {
 					playlistId: res.playlistId,
@@ -93,7 +94,7 @@ CacheModule.runJob("SUB", {
 CacheModule.runJob("SUB", {
 	channel: "playlist.updateDisplayName",
 	cb: res => {
-		UtilsModule.runJob("SOCKETS_FROM_USER", { userId: res.userId }).then(response => {
+		IOModule.runJob("SOCKETS_FROM_USER", { userId: res.userId }).then(response => {
 			response.sockets.forEach(socket => {
 				socket.emit("event:playlist.updateDisplayName", {
 					playlistId: res.playlistId,

+ 9 - 7
backend/logic/actions/punishments.js

@@ -1,21 +1,23 @@
 import async from "async";
 
 import { isAdminRequired } from "./hooks";
-// const moduleManager = require("../../index");
 
-import DBModule from "../db";
-import UtilsModule from "../utils";
-import CacheModule from "../cache";
-import PunishmentsModule from "../punishments";
+import moduleManager from "../../index";
+
+const DBModule = moduleManager.modules.db;
+const UtilsModule = moduleManager.modules.utils;
+const IOModule = moduleManager.modules.io;
+const CacheModule = moduleManager.modules.cache;
+const PunishmentsModule = moduleManager.modules.punishments;
 
 CacheModule.runJob("SUB", {
 	channel: "ip.ban",
 	cb: data => {
-		UtilsModule.runJob("EMIT_TO_ROOM", {
+		IOModule.runJob("EMIT_TO_ROOM", {
 			room: "admin.punishments",
 			args: ["event:admin.punishment.added", data.punishment]
 		});
-		UtilsModule.runJob("SOCKETS_FROM_IP", { ip: data.ip }).then(sockets => {
+		IOModule.runJob("SOCKETS_FROM_IP", { ip: data.ip }).then(sockets => {
 			sockets.forEach(socket => {
 				socket.disconnect(true);
 			});

+ 10 - 7
backend/logic/actions/queueSongs.js

@@ -4,10 +4,13 @@ import async from "async";
 
 import { isAdminRequired, isLoginRequired } from "./hooks";
 
-import DBModule from "../db";
-import UtilsModule from "../utils";
-import YouTubeModule from "../youtube";
-import CacheModule from "../cache";
+import moduleManager from "../../index";
+
+const DBModule = moduleManager.modules.db;
+const UtilsModule = moduleManager.modules.utils;
+const IOModule = moduleManager.modules.io;
+const YouTubeModule = moduleManager.modules.youtube;
+const CacheModule = moduleManager.modules.cache;
 
 CacheModule.runJob("SUB", {
 	channel: "queue.newSong",
@@ -16,7 +19,7 @@ CacheModule.runJob("SUB", {
 			modelName: "queueSong"
 		});
 		queueSongModel.findOne({ _id: songId }, (err, song) => {
-			UtilsModule.runJob("EMIT_TO_ROOM", {
+			IOModule.runJob("EMIT_TO_ROOM", {
 				room: "admin.queue",
 				args: ["event:admin.queueSong.added", song]
 			});
@@ -27,7 +30,7 @@ CacheModule.runJob("SUB", {
 CacheModule.runJob("SUB", {
 	channel: "queue.removedSong",
 	cb: songId => {
-		UtilsModule.runJob("EMIT_TO_ROOM", {
+		IOModule.runJob("EMIT_TO_ROOM", {
 			room: "admin.queue",
 			args: ["event:admin.queueSong.removed", songId]
 		});
@@ -41,7 +44,7 @@ CacheModule.runJob("SUB", {
 			modelName: "queueSong"
 		});
 		queueSongModel.findOne({ _id: songId }, (err, song) => {
-			UtilsModule.runJob("EMIT_TO_ROOM", {
+			IOModule.runJob("EMIT_TO_ROOM", {
 				room: "admin.queue",
 				args: ["event:admin.queueSong.updated", song]
 			});

+ 9 - 6
backend/logic/actions/reports.js

@@ -2,10 +2,13 @@ import async from "async";
 
 import { isAdminRequired, isLoginRequired } from "./hooks";
 
-import DBModule from "../db";
-import UtilsModule from "../utils";
-import SongsModule from "../songs";
-import CacheModule from "../cache";
+import moduleManager from "../../index";
+
+const DBModule = moduleManager.modules.db;
+const UtilsModule = moduleManager.modules.utils;
+const IOModule = moduleManager.modules.io;
+const SongsModule = moduleManager.modules.songs;
+const CacheModule = moduleManager.modules.cache;
 
 const reportableIssues = [
 	{
@@ -33,7 +36,7 @@ const reportableIssues = [
 CacheModule.runJob("SUB", {
 	channel: "report.resolve",
 	cb: reportId => {
-		UtilsModule.runJob("EMIT_TO_ROOM", {
+		IOModule.runJob("EMIT_TO_ROOM", {
 			room: "admin.reports",
 			args: ["event:admin.report.resolved", reportId]
 		});
@@ -43,7 +46,7 @@ CacheModule.runJob("SUB", {
 CacheModule.runJob("SUB", {
 	channel: "report.create",
 	cb: report => {
-		UtilsModule.runJob("EMIT_TO_ROOM", {
+		IOModule.runJob("EMIT_TO_ROOM", {
 			room: "admin.reports",
 			args: ["event:admin.report.created", report]
 		});

+ 19 - 18
backend/logic/actions/songs.js

@@ -2,20 +2,21 @@ import async from "async";
 
 import { isAdminRequired, isLoginRequired } from "./hooks";
 
-// const moduleManager = require("../../index");
-
-import DBModule from "../db";
-import UtilsModule from "../utils";
-import CacheModule from "../cache";
-import SongsModule from "../songs";
-import ActivitiesModule from "../activities";
+import moduleManager from "../../index";
 
 import queueSongs from "./queueSongs";
 
+const DBModule = moduleManager.modules.db;
+const UtilsModule = moduleManager.modules.utils;
+const IOModule = moduleManager.modules.io;
+const CacheModule = moduleManager.modules.cache;
+const SongsModule = moduleManager.modules.songs;
+const ActivitiesModule = moduleManager.modules.activities;
+
 CacheModule.runJob("SUB", {
 	channel: "song.removed",
 	cb: songId => {
-		UtilsModule.runJob("EMIT_TO_ROOM", {
+		IOModule.runJob("EMIT_TO_ROOM", {
 			room: "admin.songs",
 			args: ["event:admin.song.removed", songId]
 		});
@@ -27,7 +28,7 @@ CacheModule.runJob("SUB", {
 	cb: async songId => {
 		const songModel = await DBModule.runJob("GET_MODEL", { modelName: "song" });
 		songModel.findOne({ _id: songId }, (err, song) => {
-			UtilsModule.runJob("EMIT_TO_ROOM", {
+			IOModule.runJob("EMIT_TO_ROOM", {
 				room: "admin.songs",
 				args: ["event:admin.song.added", song]
 			});
@@ -40,7 +41,7 @@ CacheModule.runJob("SUB", {
 	cb: async songId => {
 		const songModel = await DBModule.runJob("GET_MODEL", { modelName: "song" });
 		songModel.findOne({ _id: songId }, (err, song) => {
-			UtilsModule.runJob("EMIT_TO_ROOM", {
+			IOModule.runJob("EMIT_TO_ROOM", {
 				room: "admin.songs",
 				args: ["event:admin.song.updated", song]
 			});
@@ -51,7 +52,7 @@ CacheModule.runJob("SUB", {
 CacheModule.runJob("SUB", {
 	channel: "song.like",
 	cb: data => {
-		UtilsModule.runJob("EMIT_TO_ROOM", {
+		IOModule.runJob("EMIT_TO_ROOM", {
 			room: `song.${data.songId}`,
 			args: [
 				"event:song.like",
@@ -62,7 +63,7 @@ CacheModule.runJob("SUB", {
 				}
 			]
 		});
-		UtilsModule.runJob("SOCKETS_FROM_USER", { userId: data.userId }).then(response => {
+		IOModule.runJob("SOCKETS_FROM_USER", { userId: data.userId }).then(response => {
 			response.sockets.forEach(socket => {
 				socket.emit("event:song.newRatings", {
 					songId: data.songId,
@@ -77,7 +78,7 @@ CacheModule.runJob("SUB", {
 CacheModule.runJob("SUB", {
 	channel: "song.dislike",
 	cb: data => {
-		UtilsModule.runJob("EMIT_TO_ROOM", {
+		IOModule.runJob("EMIT_TO_ROOM", {
 			room: `song.${data.songId}`,
 			args: [
 				"event:song.dislike",
@@ -88,7 +89,7 @@ CacheModule.runJob("SUB", {
 				}
 			]
 		});
-		UtilsModule.runJob("SOCKETS_FROM_USER", { userId: data.userId }).then(response => {
+		IOModule.runJob("SOCKETS_FROM_USER", { userId: data.userId }).then(response => {
 			response.sockets.forEach(socket => {
 				socket.emit("event:song.newRatings", {
 					songId: data.songId,
@@ -103,7 +104,7 @@ CacheModule.runJob("SUB", {
 CacheModule.runJob("SUB", {
 	channel: "song.unlike",
 	cb: data => {
-		UtilsModule.runJob("EMIT_TO_ROOM", {
+		IOModule.runJob("EMIT_TO_ROOM", {
 			room: `song.${data.songId}`,
 			args: [
 				"event:song.unlike",
@@ -114,7 +115,7 @@ CacheModule.runJob("SUB", {
 				}
 			]
 		});
-		UtilsModule.runJob("SOCKETS_FROM_USER", { userId: data.userId }).then(response => {
+		IOModule.runJob("SOCKETS_FROM_USER", { userId: data.userId }).then(response => {
 			response.sockets.forEach(socket => {
 				socket.emit("event:song.newRatings", {
 					songId: data.songId,
@@ -129,7 +130,7 @@ CacheModule.runJob("SUB", {
 CacheModule.runJob("SUB", {
 	channel: "song.undislike",
 	cb: data => {
-		UtilsModule.runJob("EMIT_TO_ROOM", {
+		IOModule.runJob("EMIT_TO_ROOM", {
 			room: `song.${data.songId}`,
 			args: [
 				"event:song.undislike",
@@ -140,7 +141,7 @@ CacheModule.runJob("SUB", {
 				}
 			]
 		});
-		UtilsModule.runJob("SOCKETS_FROM_USER", { userId: data.userId }).then(response => {
+		IOModule.runJob("SOCKETS_FROM_USER", { userId: data.userId }).then(response => {
 			response.sockets.forEach(socket => {
 				socket.emit("event:song.newRatings", {
 					songId: data.songId,

+ 32 - 31
backend/logic/actions/stations.js

@@ -2,16 +2,17 @@ import async from "async";
 
 import { isLoginRequired, isOwnerRequired } from "./hooks";
 
-import DBModule from "../db";
-import UtilsModule from "../utils";
-import SongsModule from "../songs";
-import CacheModule from "../cache";
-import NotificationsModule from "../notifications";
-import StationsModule from "../stations";
-import ActivitiesModule from "../activities";
-import YouTubeModule from "../youtube";
-
-// const logger = moduleManager.modules["logger"];
+import moduleManager from "../../index";
+
+const DBModule = moduleManager.modules.db;
+const UtilsModule = moduleManager.modules.utils;
+const IOModule = moduleManager.modules.io;
+const SongsModule = moduleManager.modules.songs;
+const CacheModule = moduleManager.modules.cache;
+const NotificationsModule = moduleManager.modules.notifications;
+const StationsModule = moduleManager.modules.stations;
+const ActivitiesModule = moduleManager.modules.activities;
+const YouTubeModule = moduleManager.modules.youtube;
 
 const userList = {};
 const usersPerStation = {};
@@ -35,7 +36,7 @@ const usersPerStationCount = {};
 // 	async.each(
 // 		Object.keys(userList),
 // 		(socketId, next) => {
-// 			UtilsModule.runJob("SOCKET_FROM_SESSION", { socketId }, { isQuiet: true }).then(socket => {
+// 			IOModule.runJob("SOCKET_FROM_SESSION", { socketId }, { isQuiet: true }).then(socket => {
 // 				const stationId = userList[socketId];
 // 				if (!socket || Object.keys(socket.rooms).indexOf(`station.${stationId}`) === -1) {
 // 					if (stationsCountUpdated.indexOf(stationId) === -1) stationsCountUpdated.push(stationId);
@@ -125,7 +126,7 @@ CacheModule.runJob("SUB", {
 	channel: "station.updateUsers",
 	cb: stationId => {
 		const list = usersPerStation[stationId] || [];
-		UtilsModule.runJob("EMIT_TO_ROOM", {
+		IOModule.runJob("EMIT_TO_ROOM", {
 			room: `station.${stationId}`,
 			args: ["event:users.updated", list]
 		});
@@ -136,18 +137,18 @@ CacheModule.runJob("SUB", {
 	channel: "station.updateUserCount",
 	cb: stationId => {
 		const count = usersPerStationCount[stationId] || 0;
-		UtilsModule.runJob("EMIT_TO_ROOM", {
+		IOModule.runJob("EMIT_TO_ROOM", {
 			room: `station.${stationId}`,
 			args: ["event:userCount.updated", count]
 		});
 		StationsModule.runJob("GET_STATION", { stationId }).then(async station => {
 			if (station.privacy === "public")
-				UtilsModule.runJob("EMIT_TO_ROOM", {
+				IOModule.runJob("EMIT_TO_ROOM", {
 					room: "home",
 					args: ["event:userCount.updated", stationId, count]
 				});
 			else {
-				const sockets = await UtilsModule.runJob("GET_ROOM_SOCKETS", {
+				const sockets = await IOModule.runJob("GET_ROOM_SOCKETS", {
 					room: "home"
 				});
 				Object.keys(sockets).forEach(socketKey => {
@@ -180,7 +181,7 @@ CacheModule.runJob("SUB", {
 CacheModule.runJob("SUB", {
 	channel: "station.queueLockToggled",
 	cb: data => {
-		UtilsModule.runJob("EMIT_TO_ROOM", {
+		IOModule.runJob("EMIT_TO_ROOM", {
 			room: `station.${data.stationId}`,
 			args: ["event:queueLockToggled", data.locked]
 		});
@@ -190,7 +191,7 @@ CacheModule.runJob("SUB", {
 CacheModule.runJob("SUB", {
 	channel: "station.updatePartyMode",
 	cb: data => {
-		UtilsModule.runJob("EMIT_TO_ROOM", {
+		IOModule.runJob("EMIT_TO_ROOM", {
 			room: `station.${data.stationId}`,
 			args: ["event:partyMode.updated", data.partyMode]
 		});
@@ -200,7 +201,7 @@ CacheModule.runJob("SUB", {
 CacheModule.runJob("SUB", {
 	channel: "privatePlaylist.selected",
 	cb: data => {
-		UtilsModule.runJob("EMIT_TO_ROOM", {
+		IOModule.runJob("EMIT_TO_ROOM", {
 			room: `station.${data.stationId}`,
 			args: ["event:privatePlaylist.selected", data.playlistId]
 		});
@@ -211,7 +212,7 @@ CacheModule.runJob("SUB", {
 	channel: "station.pause",
 	cb: stationId => {
 		StationsModule.runJob("GET_STATION", { stationId }).then(station => {
-			UtilsModule.runJob("EMIT_TO_ROOM", {
+			IOModule.runJob("EMIT_TO_ROOM", {
 				room: `station.${stationId}`,
 				args: ["event:stations.pause", { pausedAt: station.pausedAt }]
 			});
@@ -223,7 +224,7 @@ CacheModule.runJob("SUB", {
 	channel: "station.resume",
 	cb: stationId => {
 		StationsModule.runJob("GET_STATION", { stationId }).then(station => {
-			UtilsModule.runJob("EMIT_TO_ROOM", {
+			IOModule.runJob("EMIT_TO_ROOM", {
 				room: `station.${stationId}`,
 				args: ["event:stations.resume", { timePaused: station.timePaused }]
 			});
@@ -235,7 +236,7 @@ CacheModule.runJob("SUB", {
 	channel: "station.queueUpdate",
 	cb: stationId => {
 		StationsModule.runJob("GET_STATION", { stationId }).then(station => {
-			UtilsModule.runJob("EMIT_TO_ROOM", {
+			IOModule.runJob("EMIT_TO_ROOM", {
 				room: `station.${stationId}`,
 				args: ["event:queue.update", station.queue]
 			});
@@ -246,7 +247,7 @@ CacheModule.runJob("SUB", {
 CacheModule.runJob("SUB", {
 	channel: "station.voteSkipSong",
 	cb: stationId => {
-		UtilsModule.runJob("EMIT_TO_ROOM", {
+		IOModule.runJob("EMIT_TO_ROOM", {
 			room: `station.${stationId}`,
 			args: ["event:song.voteSkipSong"]
 		});
@@ -256,11 +257,11 @@ CacheModule.runJob("SUB", {
 CacheModule.runJob("SUB", {
 	channel: "station.remove",
 	cb: stationId => {
-		UtilsModule.runJob("EMIT_TO_ROOM", {
+		IOModule.runJob("EMIT_TO_ROOM", {
 			room: `station.${stationId}`,
 			args: ["event:stations.remove"]
 		});
-		UtilsModule.runJob("EMIT_TO_ROOM", {
+		IOModule.runJob("EMIT_TO_ROOM", {
 			room: "admin.stations",
 			args: ["event:admin.station.removed", stationId]
 		});
@@ -275,18 +276,18 @@ CacheModule.runJob("SUB", {
 		StationsModule.runJob("INITIALIZE_STATION", { stationId }).then(async response => {
 			const { station } = response;
 			station.userCount = usersPerStationCount[stationId] || 0;
-			UtilsModule.runJob("EMIT_TO_ROOM", {
+			IOModule.runJob("EMIT_TO_ROOM", {
 				room: "admin.stations",
 				args: ["event:admin.station.added", station]
 			});
 			// TODO If community, check if on whitelist
 			if (station.privacy === "public")
-				UtilsModule.runJob("EMIT_TO_ROOM", {
+				IOModule.runJob("EMIT_TO_ROOM", {
 					room: "home",
 					args: ["event:stations.created", station]
 				});
 			else {
-				const sockets = await UtilsModule.runJob("GET_ROOM_SOCKETS", {
+				const sockets = await IOModule.runJob("GET_ROOM_SOCKETS", {
 					room: "home"
 				});
 				Object.keys(sockets).forEach(socketKey => {
@@ -570,7 +571,7 @@ export default {
 				},
 
 				(station, next) => {
-					UtilsModule.runJob("SOCKET_JOIN_ROOM", {
+					IOModule.runJob("SOCKET_JOIN_ROOM", {
 						socketId: session.socketId,
 						room: `station.${station._id}`
 					});
@@ -599,7 +600,7 @@ export default {
 					data.userCount = usersPerStationCount[data._id] || 0;
 					data.users = usersPerStation[data._id] || [];
 					if (!data.currentSong || !data.currentSong.title) return next(null, data);
-					UtilsModule.runJob("SOCKET_JOIN_SONG_ROOM", {
+					IOModule.runJob("SOCKET_JOIN_SONG_ROOM", {
 						socketId: session.socketId,
 						room: `song.${data.currentSong.songId}`
 					});
@@ -766,7 +767,7 @@ export default {
 
 				(station, next) => {
 					skipVotes = station.currentSong.skipVotes.length;
-					UtilsModule.runJob("GET_ROOM_SOCKETS", {
+					IOModule.runJob("GET_ROOM_SOCKETS", {
 						room: `station.${stationId}`
 					})
 						.then(sockets => {
@@ -878,7 +879,7 @@ export default {
 					return cb({ status: "failure", message: err });
 				}
 				console.log("SUCCESS", "STATIONS_LEAVE", `Left station "${stationId}" successfully.`);
-				UtilsModule.runJob("SOCKET_LEAVE_ROOMS", { socketId: session });
+				IOModule.runJob("SOCKET_LEAVE_ROOMS", { socketId: session });
 				delete userList[session.socketId];
 				return cb({
 					status: "success",

+ 17 - 16
backend/logic/actions/users.js

@@ -7,19 +7,20 @@ import bcrypt from "bcrypt";
 import sha256 from "sha256";
 import { isAdminRequired, isLoginRequired } from "./hooks";
 
-// const moduleManager = require("../../index");
+import moduleManager from "../../index";
 
-import DBModule from "../db";
-import UtilsModule from "../utils";
-import CacheModule from "../cache";
-import MailModule from "../mail";
-import PunishmentsModule from "../punishments";
-import ActivitiesModule from "../activities";
+const DBModule = moduleManager.modules.db;
+const UtilsModule = moduleManager.modules.utils;
+const IOModule = moduleManager.modules.io;
+const CacheModule = moduleManager.modules.cache;
+const MailModule = moduleManager.modules.mail;
+const PunishmentsModule = moduleManager.modules.punishments;
+const ActivitiesModule = moduleManager.modules.activities;
 
 CacheModule.runJob("SUB", {
 	channel: "user.updateUsername",
 	cb: user => {
-		UtilsModule.runJob("SOCKETS_FROM_USER", { userId: user._id }).then(response => {
+		IOModule.runJob("SOCKETS_FROM_USER", { userId: user._id }).then(response => {
 			response.sockets.forEach(socket => {
 				socket.emit("event:user.username.changed", user.username);
 			});
@@ -30,7 +31,7 @@ CacheModule.runJob("SUB", {
 CacheModule.runJob("SUB", {
 	channel: "user.removeSessions",
 	cb: userId => {
-		UtilsModule.runJob("SOCKETS_FROM_USER_WITHOUT_CACHE", { userId }).then(response => {
+		IOModule.runJob("SOCKETS_FROM_USER_WITHOUT_CACHE", { userId }).then(response => {
 			response.sockets.forEach(socket => {
 				socket.emit("keep.event:user.session.removed");
 			});
@@ -41,7 +42,7 @@ CacheModule.runJob("SUB", {
 CacheModule.runJob("SUB", {
 	channel: "user.linkPassword",
 	cb: userId => {
-		UtilsModule.runJob("SOCKETS_FROM_USER", { userId }).then(response => {
+		IOModule.runJob("SOCKETS_FROM_USER", { userId }).then(response => {
 			response.sockets.forEach(socket => {
 				socket.emit("event:user.linkPassword");
 			});
@@ -52,7 +53,7 @@ CacheModule.runJob("SUB", {
 CacheModule.runJob("SUB", {
 	channel: "user.unlinkPassword",
 	cb: userId => {
-		UtilsModule.runJob("SOCKETS_FROM_USER", { userId }).then(response => {
+		IOModule.runJob("SOCKETS_FROM_USER", { userId }).then(response => {
 			response.sockets.forEach(socket => {
 				socket.emit("event:user.unlinkPassword");
 			});
@@ -63,7 +64,7 @@ CacheModule.runJob("SUB", {
 CacheModule.runJob("SUB", {
 	channel: "user.linkGithub",
 	cb: userId => {
-		UtilsModule.runJob("SOCKETS_FROM_USER", { userId }).then(response => {
+		IOModule.runJob("SOCKETS_FROM_USER", { userId }).then(response => {
 			response.sockets.forEach(socket => {
 				socket.emit("event:user.linkGithub");
 			});
@@ -74,7 +75,7 @@ CacheModule.runJob("SUB", {
 CacheModule.runJob("SUB", {
 	channel: "user.unlinkGithub",
 	cb: userId => {
-		UtilsModule.runJob("SOCKETS_FROM_USER", { userId }).then(response => {
+		IOModule.runJob("SOCKETS_FROM_USER", { userId }).then(response => {
 			response.sockets.forEach(socket => {
 				socket.emit("event:user.unlinkGithub");
 			});
@@ -85,7 +86,7 @@ CacheModule.runJob("SUB", {
 CacheModule.runJob("SUB", {
 	channel: "user.ban",
 	cb: data => {
-		UtilsModule.runJob("SOCKETS_FROM_USER", { userId: data.userId }).then(response => {
+		IOModule.runJob("SOCKETS_FROM_USER", { userId: data.userId }).then(response => {
 			response.sockets.forEach(socket => {
 				socket.emit("keep.event:banned", data.punishment);
 				socket.disconnect(true);
@@ -97,7 +98,7 @@ CacheModule.runJob("SUB", {
 CacheModule.runJob("SUB", {
 	channel: "user.favoritedStation",
 	cb: data => {
-		UtilsModule.runJob("SOCKETS_FROM_USER", { userId: data.userId }).then(response => {
+		IOModule.runJob("SOCKETS_FROM_USER", { userId: data.userId }).then(response => {
 			response.sockets.forEach(socket => {
 				socket.emit("event:user.favoritedStation", data.stationId);
 			});
@@ -108,7 +109,7 @@ CacheModule.runJob("SUB", {
 CacheModule.runJob("SUB", {
 	channel: "user.unfavoritedStation",
 	cb: data => {
-		UtilsModule.runJob("SOCKETS_FROM_USER", { userId: data.userId }).then(response => {
+		IOModule.runJob("SOCKETS_FROM_USER", { userId: data.userId }).then(response => {
 			response.sockets.forEach(socket => {
 				socket.emit("event:user.unfavoritedStation", data.stationId);
 			});

+ 3 - 1
backend/logic/actions/utils.js

@@ -2,7 +2,9 @@ import async from "async";
 
 import { isAdminRequired } from "./hooks";
 
-import UtilsModule from "../utils";
+import moduleManager from "../../index";
+
+const UtilsModule = moduleManager.modules.utils;
 
 export default {
 	getModules: isAdminRequired((session, cb) => {

+ 3 - 1
backend/logic/activities.js

@@ -5,6 +5,7 @@ import CoreClass from "../core";
 // let ActivitiesModule;
 let DBModule;
 let UtilsModule;
+let IOModule;
 
 class _ActivitiesModule extends CoreClass {
 	// eslint-disable-next-line require-jsdoc
@@ -23,6 +24,7 @@ class _ActivitiesModule extends CoreClass {
 		return new Promise(resolve => {
 			DBModule = this.moduleManager.modules.db;
 			UtilsModule = this.moduleManager.modules.utils;
+			IOModule = this.moduleManager.modules.io;
 
 			resolve();
 		});
@@ -61,7 +63,7 @@ class _ActivitiesModule extends CoreClass {
 					},
 
 					(activity, next) => {
-						UtilsModule.runJob(
+						IOModule.runJob(
 							"SOCKETS_FROM_USER",
 							{
 								userId: activity.userId

+ 323 - 1
backend/logic/io.js

@@ -6,7 +6,6 @@ import config from "config";
 import async from "async";
 import socketio from "socket.io";
 
-import actions from "./actions";
 import CoreClass from "../core";
 
 let IOModule;
@@ -38,6 +37,8 @@ class _IOModule extends CoreClass {
 		DBModule = this.moduleManager.modules.db;
 		PunishmentsModule = this.moduleManager.modules.punishments;
 
+		const actions = (await import("./actions")).default;
+
 		this.userModel = await DBModule.runJob("GET_MODEL", { modelName: "user" });
 
 		this.setStage(2);
@@ -334,6 +335,327 @@ class _IOModule extends CoreClass {
 			resolve(IOModule._io);
 		});
 	}
+
+	// UNKNOWN
+	// eslint-disable-next-line require-jsdoc
+	async SOCKET_FROM_SESSION(payload) {
+		// socketId
+		return new Promise((resolve, reject) => {
+			const ns = IOModule._io.of("/");
+			if (ns) {
+				return resolve(ns.connected[payload.socketId]);
+			}
+
+			return reject();
+		});
+	}
+
+	/**
+	 * Gets all sockets for a specified session id
+	 *
+	 * @param {object} payload - object containing the payload
+	 * @param {string} payload.sessionId - user session id
+	 * @returns {Promise} - returns promise (reject, resolve)
+	 */
+	async SOCKETS_FROM_SESSION_ID(payload) {
+		return new Promise(resolve => {
+			const ns = IOModule._io.of("/");
+			const sockets = [];
+
+			if (ns) {
+				return async.each(
+					Object.keys(ns.connected),
+					(id, next) => {
+						const { session } = ns.connected[id];
+						if (session.sessionId === payload.sessionId) sockets.push(session.sessionId);
+						next();
+					},
+					() => {
+						resolve({ sockets });
+					}
+				);
+			}
+
+			return resolve();
+		});
+	}
+
+	/**
+	 * Returns any sockets for a specific user
+	 *
+	 * @param {object} payload - object that contains the payload
+	 * @param {string} payload.userId - the user id
+	 * @returns {Promise} - returns promise (reject, resolve)
+	 */
+	async SOCKETS_FROM_USER(payload) {
+		return new Promise((resolve, reject) => {
+			const ns = IOModule._io.of("/");
+			const sockets = [];
+
+			if (ns) {
+				return async.each(
+					Object.keys(ns.connected),
+					(id, next) => {
+						const { session } = ns.connected[id];
+						CacheModule.runJob(
+							"HGET",
+							{
+								table: "sessions",
+								key: session.sessionId
+							},
+							this
+						)
+							.then(session => {
+								if (session && session.userId === payload.userId) sockets.push(ns.connected[id]);
+								next();
+							})
+							.catch(err => {
+								next(err);
+							});
+					},
+					err => {
+						if (err) return reject(err);
+						return resolve({ sockets });
+					}
+				);
+			}
+
+			return resolve();
+		});
+	}
+
+	/**
+	 * Returns any sockets from a specific ip address
+	 *
+	 * @param {object} payload - object that contains the payload
+	 * @param {string} payload.ip - the ip address in question
+	 * @returns {Promise} - returns promise (reject, resolve)
+	 */
+	async SOCKETS_FROM_IP(payload) {
+		return new Promise(resolve => {
+			const ns = IOModule._io.of("/");
+			const sockets = [];
+			if (ns) {
+				return async.each(
+					Object.keys(ns.connected),
+					(id, next) => {
+						const { session } = ns.connected[id];
+						CacheModule.runJob(
+							"HGET",
+							{
+								table: "sessions",
+								key: session.sessionId
+							},
+							this
+						)
+							.then(session => {
+								if (session && ns.connected[id].ip === payload.ip) sockets.push(ns.connected[id]);
+								next();
+							})
+							.catch(() => next());
+					},
+					() => {
+						resolve({ sockets });
+					}
+				);
+			}
+
+			return resolve();
+		});
+	}
+
+	/**
+	 * Returns any sockets from a specific user without using redis/cache
+	 *
+	 * @param {object} payload - object that contains the payload
+	 * @param {string} payload.userId - the id of the user in question
+	 * @returns {Promise} - returns promise (reject, resolve)
+	 */
+	async SOCKETS_FROM_USER_WITHOUT_CACHE(payload) {
+		return new Promise(resolve => {
+			const ns = IOModule._io.of("/");
+			const sockets = [];
+
+			if (ns) {
+				return async.each(
+					Object.keys(ns.connected),
+					(id, next) => {
+						const { session } = ns.connected[id];
+						if (session.userId === payload.userId) sockets.push(ns.connected[id]);
+						next();
+					},
+					() => {
+						resolve({ sockets });
+					}
+				);
+			}
+
+			return resolve();
+		});
+	}
+
+	/**
+	 * Allows a socket to leave any rooms they are connected to
+	 *
+	 * @param {object} payload - object that contains the payload
+	 * @param {string} payload.socketId - the id of the socket which should leave all their rooms
+	 * @returns {Promise} - returns promise (reject, resolve)
+	 */
+	async SOCKET_LEAVE_ROOMS(payload) {
+		const socket = await IOModule.runJob(
+			"SOCKET_FROM_SESSION",
+			{
+				socketId: payload.socketId
+			},
+			this
+		);
+
+		return new Promise(resolve => {
+			const { rooms } = socket;
+
+			Object.keys(rooms).forEach(roomKey => {
+				const room = rooms[roomKey];
+				socket.leave(room);
+			});
+
+			return resolve();
+		});
+	}
+
+	/**
+	 * Allows a socket to join a specified room
+	 *
+	 * @param {object} payload - object that contains the payload
+	 * @param {string} payload.socketId - the id of the socket which should join the room
+	 * @param {object} payload.room - the object representing the room the socket should join
+	 * @returns {Promise} - returns promise (reject, resolve)
+	 */
+	async SOCKET_JOIN_ROOM(payload) {
+		const socket = await IOModule.runJob(
+			"SOCKET_FROM_SESSION",
+			{
+				socketId: payload.socketId
+			},
+			this
+		);
+
+		return new Promise(resolve => {
+			const { rooms } = socket;
+			Object.keys(rooms).forEach(roomKey => {
+				const room = rooms[roomKey];
+				socket.leave(room);
+			});
+
+			socket.join(payload.room);
+
+			return resolve();
+		});
+	}
+
+	// UNKNOWN
+	// eslint-disable-next-line require-jsdoc
+	async SOCKET_JOIN_SONG_ROOM(payload) {
+		// socketId, room
+		const socket = await IOModule.runJob(
+			"SOCKET_FROM_SESSION",
+			{
+				socketId: payload.socketId
+			},
+			this
+		);
+
+		return new Promise(resolve => {
+			const { rooms } = socket;
+			Object.keys(rooms).forEach(roomKey => {
+				const room = rooms[roomKey];
+				if (room.indexOf("song.") !== -1) socket.leave(room);
+			});
+
+			socket.join(payload.room);
+
+			return resolve();
+		});
+	}
+
+	// UNKNOWN
+	// eslint-disable-next-line require-jsdoc
+	SOCKETS_JOIN_SONG_ROOM(payload) {
+		// sockets, room
+		return new Promise(resolve => {
+			Object.keys(payload.sockets).forEach(socketKey => {
+				const socket = payload.sockets[socketKey];
+
+				const { rooms } = socket;
+				Object.keys(rooms).forEach(roomKey => {
+					const room = rooms[roomKey];
+					if (room.indexOf("song.") !== -1) socket.leave(room);
+				});
+
+				socket.join(payload.room);
+			});
+
+			return resolve();
+		});
+	}
+
+	// UNKNOWN
+	// eslint-disable-next-line require-jsdoc
+	SOCKETS_LEAVE_SONG_ROOMS(payload) {
+		// sockets
+		return new Promise(resolve => {
+			Object.keys(payload.sockets).forEach(socketKey => {
+				const socket = payload.sockets[socketKey];
+				const { rooms } = socket;
+				Object.keys(rooms).forEach(roomKey => {
+					const room = rooms[roomKey];
+					if (room.indexOf("song.") !== -1) socket.leave(room);
+				});
+			});
+			resolve();
+		});
+	}
+
+	/**
+	 * Emits arguments to any sockets that are in a specified a room
+	 *
+	 * @param {object} payload - object that contains the payload
+	 * @param {string} payload.room - the name of the room to emit arguments
+	 * @param {object} payload.args - any arguments to be emitted to the sockets in the specific room
+	 * @returns {Promise} - returns promise (reject, resolve)
+	 */
+	async EMIT_TO_ROOM(payload) {
+		return new Promise(resolve => {
+			const { sockets } = IOModule._io.sockets;
+			Object.keys(sockets).forEach(socketKey => {
+				const socket = sockets[socketKey];
+				if (socket.rooms[payload.room]) {
+					socket.emit(...payload.args);
+				}
+			});
+
+			return resolve();
+		});
+	}
+
+	/**
+	 * Gets any sockets connected to a room
+	 *
+	 * @param {object} payload - object that contains the payload
+	 * @param {string} payload.room - the name of the room
+	 * @returns {Promise} - returns promise (reject, resolve)
+	 */
+	async GET_ROOM_SOCKETS(payload) {
+		return new Promise(resolve => {
+			const { sockets } = IOModule._io.sockets;
+			const roomSockets = [];
+			Object.keys(sockets).forEach(socketKey => {
+				const socket = sockets[socketKey];
+				if (socket.rooms[payload.room]) roomSockets.push(socket);
+			});
+
+			return resolve(roomSockets);
+		});
+	}
 }
 
 export default new _IOModule();

+ 10 - 8
backend/logic/stations.js

@@ -6,6 +6,7 @@ let StationsModule;
 let CacheModule;
 let DBModule;
 let UtilsModule;
+let IOModule;
 let SongsModule;
 let NotificationsModule;
 
@@ -26,6 +27,7 @@ class _StationsModule extends CoreClass {
 		CacheModule = this.moduleManager.modules.cache;
 		DBModule = this.moduleManager.modules.db;
 		UtilsModule = this.moduleManager.modules.utils;
+		IOModule = this.moduleManager.modules.io;
 		SongsModule = this.moduleManager.modules.songs;
 		NotificationsModule = this.moduleManager.modules.notifications;
 
@@ -76,7 +78,7 @@ class _StationsModule extends CoreClass {
 					key: stationId
 				}).then(playlistObj => {
 					if (playlistObj) {
-						UtilsModule.runJob("EMIT_TO_ROOM", {
+						IOModule.runJob("EMIT_TO_ROOM", {
 							room: `station.${stationId}`,
 							args: ["event:newOfficialPlaylist", playlistObj.songs]
 						});
@@ -888,7 +890,7 @@ class _StationsModule extends CoreClass {
 						}
 						// TODO Pub/Sub this
 
-						UtilsModule.runJob("EMIT_TO_ROOM", {
+						IOModule.runJob("EMIT_TO_ROOM", {
 							room: `station.${station._id}`,
 							args: [
 								"event:songs.next",
@@ -904,14 +906,14 @@ class _StationsModule extends CoreClass {
 							.catch();
 
 						if (station.privacy === "public") {
-							UtilsModule.runJob("EMIT_TO_ROOM", {
+							IOModule.runJob("EMIT_TO_ROOM", {
 								room: "home",
 								args: ["event:station.nextSong", station._id, station.currentSong]
 							})
 								.then()
 								.catch();
 						} else {
-							const sockets = await UtilsModule.runJob("GET_ROOM_SOCKETS", { room: "home" }, this);
+							const sockets = await IOModule.runJob("GET_ROOM_SOCKETS", { room: "home" }, this);
 
 							Object.keys(sockets).forEach(socketKey => {
 								const socket = sockets[socketKey];
@@ -962,8 +964,8 @@ class _StationsModule extends CoreClass {
 						}
 
 						if (station.currentSong !== null && station.currentSong.songId !== undefined) {
-							UtilsModule.runJob("SOCKETS_JOIN_SONG_ROOM", {
-								sockets: await UtilsModule.runJob(
+							IOModule.runJob("SOCKETS_JOIN_SONG_ROOM", {
+								sockets: await IOModule.runJob(
 									"GET_ROOM_SOCKETS",
 									{
 										room: `station.${station._id}`
@@ -980,8 +982,8 @@ class _StationsModule extends CoreClass {
 								});
 							}
 						} else {
-							UtilsModule.runJob("SOCKETS_LEAVE_SONG_ROOMS", {
-								sockets: await UtilsModule.runJob(
+							IOModule.runJob("SOCKETS_LEAVE_SONG_ROOMS", {
+								sockets: await IOModule.runJob(
 									"GET_ROOM_SOCKETS",
 									{
 										room: `station.${station._id}`

+ 3 - 1
backend/logic/tasks.js

@@ -12,6 +12,7 @@ let TasksModule;
 let CacheModule;
 let StationsModule;
 let UtilsModule;
+let IOModule;
 
 class _TasksModule extends CoreClass {
 	// eslint-disable-next-line require-jsdoc
@@ -35,6 +36,7 @@ class _TasksModule extends CoreClass {
 			CacheModule = this.moduleManager.modules.cache;
 			StationsModule = this.moduleManager.modules.stations;
 			UtilsModule = this.moduleManager.modules.utils;
+			IOModule = this.moduleManager.modules.io;
 
 			// this.createTask("testTask", testTask, 5000, true);
 
@@ -235,7 +237,7 @@ class _TasksModule extends CoreClass {
 									}).finally(() => next2());
 								}
 								if (Date.now() - session.refreshDate > 60 * 60 * 24 * 30 * 1000) {
-									return UtilsModule.runJob("SOCKETS_FROM_SESSION_ID", {
+									return IOModule.runJob("SOCKETS_FROM_SESSION_ID", {
 										sessionId: session.sessionId
 									}).then(response => {
 										if (response.sockets.length > 0) {

+ 0 - 338
backend/logic/utils.js

@@ -1,10 +1,8 @@
-import async from "async";
 import crypto from "crypto";
 import CoreClass from "../core";
 
 let UtilsModule;
 let IOModule;
-let CacheModule;
 
 class _UtilsModule extends CoreClass {
 	// eslint-disable-next-line require-jsdoc
@@ -22,7 +20,6 @@ class _UtilsModule extends CoreClass {
 	initialize() {
 		return new Promise(resolve => {
 			IOModule = this.moduleManager.modules.io;
-			CacheModule = this.moduleManager.modules.cache;
 
 			resolve();
 		});
@@ -249,341 +246,6 @@ class _UtilsModule extends CoreClass {
 		});
 	}
 
-	// UNKNOWN
-	// eslint-disable-next-line require-jsdoc
-	async SOCKET_FROM_SESSION(payload) {
-		// socketId
-		const io = await IOModule.runJob("IO", {}, this);
-
-		return new Promise((resolve, reject) => {
-			const ns = io.of("/");
-			if (ns) {
-				return resolve(ns.connected[payload.socketId]);
-			}
-
-			return reject();
-		});
-	}
-
-	/**
-	 * Gets all sockets for a specified session id
-	 *
-	 * @param {object} payload - object containing the payload
-	 * @param {string} payload.sessionId - user session id
-	 * @returns {Promise} - returns promise (reject, resolve)
-	 */
-	async SOCKETS_FROM_SESSION_ID(payload) {
-		const io = await IOModule.runJob("IO", {}, this);
-
-		return new Promise(resolve => {
-			const ns = io.of("/");
-			const sockets = [];
-
-			if (ns) {
-				return async.each(
-					Object.keys(ns.connected),
-					(id, next) => {
-						const { session } = ns.connected[id];
-						if (session.sessionId === payload.sessionId) sockets.push(session.sessionId);
-						next();
-					},
-					() => {
-						resolve({ sockets });
-					}
-				);
-			}
-
-			return resolve();
-		});
-	}
-
-	/**
-	 * Returns any sockets for a specific user
-	 *
-	 * @param {object} payload - object that contains the payload
-	 * @param {string} payload.userId - the user id
-	 * @returns {Promise} - returns promise (reject, resolve)
-	 */
-	async SOCKETS_FROM_USER(payload) {
-		const io = await IOModule.runJob("IO", {}, this);
-
-		return new Promise((resolve, reject) => {
-			const ns = io.of("/");
-			const sockets = [];
-
-			if (ns) {
-				return async.each(
-					Object.keys(ns.connected),
-					(id, next) => {
-						const { session } = ns.connected[id];
-						CacheModule.runJob(
-							"HGET",
-							{
-								table: "sessions",
-								key: session.sessionId
-							},
-							this
-						)
-							.then(session => {
-								if (session && session.userId === payload.userId) sockets.push(ns.connected[id]);
-								next();
-							})
-							.catch(err => {
-								next(err);
-							});
-					},
-					err => {
-						if (err) return reject(err);
-						return resolve({ sockets });
-					}
-				);
-			}
-
-			return resolve();
-		});
-	}
-
-	/**
-	 * Returns any sockets from a specific ip address
-	 *
-	 * @param {object} payload - object that contains the payload
-	 * @param {string} payload.ip - the ip address in question
-	 * @returns {Promise} - returns promise (reject, resolve)
-	 */
-	async SOCKETS_FROM_IP(payload) {
-		const io = await IOModule.runJob("IO", {}, this);
-
-		return new Promise(resolve => {
-			const ns = io.of("/");
-			const sockets = [];
-			if (ns) {
-				return async.each(
-					Object.keys(ns.connected),
-					(id, next) => {
-						const { session } = ns.connected[id];
-						CacheModule.runJob(
-							"HGET",
-							{
-								table: "sessions",
-								key: session.sessionId
-							},
-							this
-						)
-							.then(session => {
-								if (session && ns.connected[id].ip === payload.ip) sockets.push(ns.connected[id]);
-								next();
-							})
-							.catch(() => next());
-					},
-					() => {
-						resolve({ sockets });
-					}
-				);
-			}
-
-			return resolve();
-		});
-	}
-
-	/**
-	 * Returns any sockets from a specific user without using redis/cache
-	 *
-	 * @param {object} payload - object that contains the payload
-	 * @param {string} payload.userId - the id of the user in question
-	 * @returns {Promise} - returns promise (reject, resolve)
-	 */
-	async SOCKETS_FROM_USER_WITHOUT_CACHE(payload) {
-		const io = await IOModule.runJob("IO", {}, this);
-
-		return new Promise(resolve => {
-			const ns = io.of("/");
-			const sockets = [];
-
-			if (ns) {
-				return async.each(
-					Object.keys(ns.connected),
-					(id, next) => {
-						const { session } = ns.connected[id];
-						if (session.userId === payload.userId) sockets.push(ns.connected[id]);
-						next();
-					},
-					() => {
-						resolve({ sockets });
-					}
-				);
-			}
-
-			return resolve();
-		});
-	}
-
-	/**
-	 * Allows a socket to leave any rooms they are connected to
-	 *
-	 * @param {object} payload - object that contains the payload
-	 * @param {string} payload.socketId - the id of the socket which should leave all their rooms
-	 * @returns {Promise} - returns promise (reject, resolve)
-	 */
-	async SOCKET_LEAVE_ROOMS(payload) {
-		const socket = await UtilsModule.runJob(
-			"SOCKET_FROM_SESSION",
-			{
-				socketId: payload.socketId
-			},
-			this
-		);
-
-		return new Promise(resolve => {
-			const { rooms } = socket;
-
-			Object.keys(rooms).forEach(roomKey => {
-				const room = rooms[roomKey];
-				socket.leave(room);
-			});
-
-			return resolve();
-		});
-	}
-
-	/**
-	 * Allows a socket to join a specified room
-	 *
-	 * @param {object} payload - object that contains the payload
-	 * @param {string} payload.socketId - the id of the socket which should join the room
-	 * @param {object} payload.room - the object representing the room the socket should join
-	 * @returns {Promise} - returns promise (reject, resolve)
-	 */
-	async SOCKET_JOIN_ROOM(payload) {
-		const socket = await UtilsModule.runJob(
-			"SOCKET_FROM_SESSION",
-			{
-				socketId: payload.socketId
-			},
-			this
-		);
-
-		return new Promise(resolve => {
-			const { rooms } = socket;
-			Object.keys(rooms).forEach(roomKey => {
-				const room = rooms[roomKey];
-				socket.leave(room);
-			});
-
-			socket.join(payload.room);
-
-			return resolve();
-		});
-	}
-
-	// UNKNOWN
-	// eslint-disable-next-line require-jsdoc
-	async SOCKET_JOIN_SONG_ROOM(payload) {
-		// socketId, room
-		const socket = await UtilsModule.runJob(
-			"SOCKET_FROM_SESSION",
-			{
-				socketId: payload.socketId
-			},
-			this
-		);
-
-		return new Promise(resolve => {
-			const { rooms } = socket;
-			Object.keys(rooms).forEach(roomKey => {
-				const room = rooms[roomKey];
-				if (room.indexOf("song.") !== -1) socket.leave(room);
-			});
-
-			socket.join(payload.room);
-
-			return resolve();
-		});
-	}
-
-	// UNKNOWN
-	// eslint-disable-next-line require-jsdoc
-	SOCKETS_JOIN_SONG_ROOM(payload) {
-		// sockets, room
-		return new Promise(resolve => {
-			Object.keys(payload.sockets).forEach(socketKey => {
-				const socket = payload.sockets[socketKey];
-
-				const { rooms } = socket;
-				Object.keys(rooms).forEach(roomKey => {
-					const room = rooms[roomKey];
-					if (room.indexOf("song.") !== -1) socket.leave(room);
-				});
-
-				socket.join(payload.room);
-			});
-
-			return resolve();
-		});
-	}
-
-	// UNKNOWN
-	// eslint-disable-next-line require-jsdoc
-	SOCKETS_LEAVE_SONG_ROOMS(payload) {
-		// sockets
-		return new Promise(resolve => {
-			Object.keys(payload.sockets).forEach(socketKey => {
-				const socket = payload.sockets[socketKey];
-				const { rooms } = socket;
-				Object.keys(rooms).forEach(roomKey => {
-					const room = rooms[roomKey];
-					if (room.indexOf("song.") !== -1) socket.leave(room);
-				});
-			});
-			resolve();
-		});
-	}
-
-	/**
-	 * Emits arguments to any sockets that are in a specified a room
-	 *
-	 * @param {object} payload - object that contains the payload
-	 * @param {string} payload.room - the name of the room to emit arguments
-	 * @param {object} payload.args - any arguments to be emitted to the sockets in the specific room
-	 * @returns {Promise} - returns promise (reject, resolve)
-	 */
-	async EMIT_TO_ROOM(payload) {
-		const io = await IOModule.runJob("IO", {}, this);
-
-		return new Promise(resolve => {
-			const { sockets } = io.sockets;
-			Object.keys(sockets).forEach(socketKey => {
-				const socket = sockets[socketKey];
-				if (socket.rooms[payload.room]) {
-					socket.emit(...payload.args);
-				}
-			});
-
-			return resolve();
-		});
-	}
-
-	/**
-	 * Gets any sockets connected to a room
-	 *
-	 * @param {object} payload - object that contains the payload
-	 * @param {string} payload.room - the name of the room
-	 * @returns {Promise} - returns promise (reject, resolve)
-	 */
-	async GET_ROOM_SOCKETS(payload) {
-		const io = await IOModule.runJob("IO", {}, this);
-
-		return new Promise(resolve => {
-			const { sockets } = io.sockets;
-			const roomSockets = [];
-			Object.keys(sockets).forEach(socketKey => {
-				const socket = sockets[socketKey];
-				if (socket.rooms[payload.room]) roomSockets.push(socket);
-			});
-
-			return resolve(roomSockets);
-		});
-	}
-
 	/**
 	 * Shuffles an array of songs
 	 *