mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-18 22:33:44 +02:00
Handle connecting to websocket instance
Very beta code for handling sockets
This commit is contained in:
22
resources/scripts/state/models/socket.ts
Normal file
22
resources/scripts/state/models/socket.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Action, action } from 'easy-peasy';
|
||||
import Sockette from 'sockette';
|
||||
|
||||
export interface SocketState {
|
||||
instance: Sockette | null;
|
||||
connected: boolean;
|
||||
setInstance: Action<SocketState, Sockette | null>;
|
||||
setConnectionState: Action<SocketState, boolean>;
|
||||
}
|
||||
|
||||
const socket: SocketState = {
|
||||
instance: null,
|
||||
connected: false,
|
||||
setInstance: action((state, payload) => {
|
||||
state.instance = payload;
|
||||
}),
|
||||
setConnectionState: action((state, payload) => {
|
||||
state.connected = payload;
|
||||
}),
|
||||
};
|
||||
|
||||
export default socket;
|
||||
Reference in New Issue
Block a user