added factory for sockets
refactor sockets.js
Finished refactoring socket.js
Further refactor socket.js