mirror of
https://github.com/m1k1o/neko.git
synced 2025-08-06 10:20:26 +02:00
update state.
This commit is contained in:
parent
b4817b886a
commit
a98866e5cb
4 changed files with 152 additions and 59 deletions
|
@ -17,6 +17,7 @@ import {
|
|||
|
||||
import EventEmitter from 'eventemitter3'
|
||||
import { NekoWebSocket } from './websocket'
|
||||
import NekoState from '~/types/state'
|
||||
|
||||
export interface NekoEvents {
|
||||
['system.websocket']: (state: 'connected' | 'connecting' | 'disconnected') => void
|
||||
|
@ -42,9 +43,12 @@ export interface NekoEvents {
|
|||
}
|
||||
|
||||
export class NekoMessages extends EventEmitter<NekoEvents> {
|
||||
constructor(websocket: NekoWebSocket) {
|
||||
state: NekoState
|
||||
|
||||
constructor(websocket: NekoWebSocket, state: NekoState) {
|
||||
super()
|
||||
|
||||
this.state = state
|
||||
websocket.on('message', async (event: string, payload: any) => {
|
||||
// @ts-ignore
|
||||
if (typeof this[event] === 'function') {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue