Socket base, event bindings, initial socket emit
This commit is contained in:
parent
6b96b191aa
commit
861d95bd06
File diff suppressed because it is too large
Load Diff
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Logger, PluginManager, BDIpc, WebpackModules, Global } = require('./modules');
|
const { Logger, PluginManager, BDIpc, WebpackModules, SocketProxy, Global } = require('./modules');
|
||||||
|
|
||||||
class BetterDiscord {
|
class BetterDiscord {
|
||||||
|
|
||||||
|
|
|
@ -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 }
|
|
@ -28,4 +28,4 @@ class Events {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Events;
|
module.exports = { Events }
|
|
@ -25,6 +25,7 @@ class Global extends Module {
|
||||||
window.__bd = {
|
window.__bd = {
|
||||||
setWS: this.setWS
|
setWS: this.setWS
|
||||||
}
|
}
|
||||||
|
Events.emit('socket-created');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,3 +5,4 @@ export { BDIpc } from './bdipc';
|
||||||
export { WebpackModules } from './webpackmodules';
|
export { WebpackModules } from './webpackmodules';
|
||||||
export { Global } from './global';
|
export { Global } from './global';
|
||||||
export { Events } from './events';
|
export { Events } from './events';
|
||||||
|
export { SocketProxy } from './discordsocket';
|
|
@ -26,6 +26,7 @@ class Module {
|
||||||
init() {
|
init() {
|
||||||
if (this.bindings) this.bindings();
|
if (this.bindings) this.bindings();
|
||||||
if (this.setInitialState) this.setInitialState(this.state);
|
if (this.setInitialState) this.setInitialState(this.state);
|
||||||
|
if (this.events) this.events();
|
||||||
}
|
}
|
||||||
|
|
||||||
setState(newState) {
|
setState(newState) {
|
||||||
|
|
Loading…
Reference in New Issue