瀏覽代碼

Fixed some things and ranted.

KrisVos130 8 年之前
父節點
當前提交
e328e1d300
共有 3 個文件被更改,包括 13 次插入19 次删除
  1. 4 4
      logic/coreHandler.js
  2. 2 8
      logic/expressHandler.js
  3. 7 7
      logic/socketHandler.js

+ 4 - 4
logic/coreHandler.js

@@ -197,7 +197,7 @@ module.exports = {
 		dbConnection = dbConn;
 	},
 
-	disconnect: function () {
+	disconnect: function () {//TODO Find out why we even need this.
 
 	},
 
@@ -248,7 +248,7 @@ module.exports = {
 		cb(_rooms);
 	},
 
-	handleRoomJoin: function (id, cb) {
+	joinRoom: function (id, cb) {//TODO Think of a better name than joinRoom
 
 		var room = getStation(id);
 		socket.custom.roomId = id;
@@ -263,7 +263,7 @@ module.exports = {
 				otherSocket.emit('roomUserJoin', { user: userInfo });
 			}
 		});
-
+		//TODO Add errors.
 		return cb({
 			status: 'joined',
 			data: {
@@ -272,7 +272,7 @@ module.exports = {
 		});
 	},
 
-	search: function (query, cb) {
+	search: function (query, cb) {//TODO Replace search with a better name.
 		request('https://www.googleapis.com/youtube/v3/search?' + [
 				'part=snippet', `q=${encodeURIComponent(query)}`, `key=${config.get('apis.youtube.key')}`, 'type=video', 'maxResults=25'
 			].join('&'), (err, res, body) => {

+ 2 - 8
logic/expressHandler.js

@@ -1,6 +1,6 @@
 'use strict';
 
-module.exports = function (base, io) {
+module.exports = function (base, io) {//TODO Rename base to core
 
 	app.post('/login', function (user) {
 		base.login(user, function (result) {
@@ -20,13 +20,7 @@ module.exports = function (base, io) {
 		});
 	});
 
-	app.get('/room/:id', function (id) {
-		base.room(id, function (result) {
-			res.send(JSON.stringify(result));
-		});
-	});
-
-	app.get('/search/:query', function () {
+	app.get('/search/:query', function () {//TODO Replace search with a better name.
 		base.search(query, function (result) {
 			res.send(JSON.stringify(result));
 		});

+ 7 - 7
logic/socketHandler.js

@@ -10,15 +10,15 @@ module.exports = function (base, io) {
 			});
 		});
 
-		socket.on('login', function (user) {
+		socket.on('login', function (user, cb) {
 			base.login(user, function (result) {
-				socket.emit('login', result);
+				cb(result);
 			});
 		});
 
-		socket.on('register', function (user) {
+		socket.on('register', function (user, cb) {
 			base.register(user, function (result) {
-				socket.emit('register', result);
+				cb(result);
 			});
 		});
 
@@ -28,7 +28,7 @@ module.exports = function (base, io) {
 			});
 		});
 
-		socket.on('room', function (id, cb) {
+		socket.on('room', function (id, cb) {//TODO Replace 'room' with a better name.
 			base.room(id, function (result) {
 				var info = {
 					displayName: result.getDisplayName(),
@@ -39,13 +39,13 @@ module.exports = function (base, io) {
 			});
 		});
 
-		socket.on('search', function (query) {
+		socket.on('search', function (query) {//TODO Replace search with a better name.
 			base.search(query, function (result) {
 				socket.emit('search', result);
 			});
 		});
 
-		socket.emit('ready');
+		socket.emit('ready');//TODO Remove this
 
 	});
 };