Socket base, event bindings, initial socket emit

This commit is contained in:
Jiiks 2018-01-15 06:40:24 +02:00
parent 6b96b191aa
commit 861d95bd06
7 changed files with 792 additions and 403 deletions

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,7 @@
'use strict';
const { Logger, PluginManager, BDIpc, WebpackModules, Global } = require('./modules');
const { Logger, PluginManager, BDIpc, WebpackModules, SocketProxy, Global } = require('./modules');
class BetterDiscord {

View File

@ -0,0 +1,33 @@
/**
* BetterDiscord Discord Socket Proxy
* Copyright (c) 2015-present JsSucks - https://github.com/JsSucks
* All rights reserved.
* https://github.com/JsSucks - https://betterdiscord.net
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
const { Events } = require('./events');
const { Module } = require('./modulebase');
const { Global } = require('./global');
class SocketProxy extends Module {
events() {
Events.on('socket-created', this.socketCreated);
}
bindings() {
this.socketCreated = this.socketCreated.bind(this);
}
socketCreated() {
console.log('SOCKET CREATED!');
console.log(Global.getObject('wsHook'));
}
}
const _instance = new SocketProxy();
module.exports = { 'SocketProxy': _instance }

View File

@ -28,4 +28,4 @@ class Events {
}
module.exports = Events;
module.exports = { Events }

View File

@ -25,6 +25,7 @@ class Global extends Module {
window.__bd = {
setWS: this.setWS
}
Events.emit('socket-created');
}
}

View File

@ -4,4 +4,5 @@ export { Pluging } from './plugin';
export { BDIpc } from './bdipc';
export { WebpackModules } from './webpackmodules';
export { Global } from './global';
export { Events } from './events';
export { Events } from './events';
export { SocketProxy } from './discordsocket';

View File

@ -26,6 +26,7 @@ class Module {
init() {
if (this.bindings) this.bindings();
if (this.setInitialState) this.setInitialState(this.state);
if (this.events) this.events();
}
setState(newState) {