CrushedPixel

Untitled

Jan 30th, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Connection(socket, user, orm) {
  2.     this.socket = socket;
  3.     this.user = user;
  4.     this.orm = orm;
  5.  
  6.     this.socket.client.connection = this;
  7.  
  8.     // register all handlers
  9.     this.socket.on('listFriends', this.listFriends.bind(this));
  10.     this.socket.on('befriend', this.befriend.bind(this));
  11. }
  12.  
  13. Connection.prototype.listFriends = (data) => {
  14.     console.log(this);
  15.     let relations = this.orm.Relation.findAll({
  16.         where: {
  17.             $or: [
  18.                 {Initiator: this.user},
  19.                 {Target: this.user}
  20.             ]
  21.         }
  22.     });
  23.  
  24.     this.socket.emit('listFriends', { data: relations }); //TODO
  25. };
  26.  
  27. Connection.prototype.befriend = (data) => {
  28.  
  29. };
  30.  
  31. module.exports = Connection;
Advertisement
Add Comment
Please, Sign In to add comment