smartsocket/ts/smartsocket.helpers.ts

20 lines
500 B
TypeScript
Raw Normal View History

2016-08-07 12:58:20 +00:00
import * as plugins from "./smartsocket.plugins";
// interfaces
import {ISocketObject} from "./smartsocket.classes.smartsocket";
/**
* authenticate a socket
*/
export let authenticateSocket = (socketObjectArg: ISocketObject) => {
let done = plugins.q.defer();
socketObjectArg.socket.on("dataAuth", data => {
socketObjectArg.socket.removeListener("dataAuth", () => { });
done.resolve();
});
socketObjectArg.socket.emit("requestAuth");
return done.promise;
};