mirror of
https://github.com/glenndehaan/unifi-voucher-site.git
synced 2026-03-31 06:24:00 -04:00
33 lines
645 B
JavaScript
33 lines
645 B
JavaScript
import io from 'socket.io-client';
|
|
|
|
class Socket {
|
|
constructor({el}) {
|
|
this.el = el;
|
|
this.socket = false;
|
|
|
|
this.init();
|
|
}
|
|
|
|
init() {
|
|
this.socket = io.connect(`http://${expressConfig.hostname}:${expressConfig.port}`);
|
|
|
|
this.socket.on('connect', this.connect);
|
|
this.socket.on('disconnect', this.disconnect);
|
|
this.socket.on('error', this.error);
|
|
}
|
|
|
|
connect() {
|
|
console.log('[SOCKET] Connected!');
|
|
}
|
|
|
|
disconnect() {
|
|
console.log('[SOCKET] Disconnected!');
|
|
}
|
|
|
|
error() {
|
|
console.log('[SOCKET] Error!');
|
|
}
|
|
}
|
|
|
|
module.exports = Socket;
|