1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00
pigallery2/backend/NetworkManager.ts
2016-03-13 11:28:29 +01:00

27 lines
909 B
TypeScript

///<reference path="../typings/tsd.d.ts"/>
import * as _socketIo from 'socket.io';
import {MessageTypes} from "../common/MessageTypes";
import {User} from "../common/entities/User";
import {LoginCredential} from "../common/entities/LoginCredential";
import * as _debug from 'debug';
var debug = _debug("PiGallery2:NetworkManager");
export class NetworkManager{
private socketIo:SocketIO.Server;
constructor(http){
this.socketIo = _socketIo(http);
this.socketIo.on('connection', function(socket:SocketIO.Server){
debug("Client Connected");
socket.on(MessageTypes.Client.Login.Authenticate,(credential:LoginCredential) =>{
debug("Message: " + MessageTypes.Client.Login.Authenticate);
socket.emit(MessageTypes.Server.Login.Authenticated,new User("Dummy user","dummy@mail.com","password"));
});
});
}
}