Refactor websocket into separate services, clean up socket status communication (#4433)

* Refactor websocket into separate services, clean up socket status communication

* cleanup

* add EOF lines

* fix keepalive logged in check

* undo change

* fix keepalive connection check

* cleanup

* add typings

* secure connection

Co-authored-by: Jeremy Letto <jeremy.letto@datasite.com>
This commit is contained in:
Jeremy Letto 2021-10-17 00:07:30 -05:00 committed by GitHub
parent 19333c53f6
commit e9ba195d7d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
52 changed files with 815 additions and 757 deletions

View file

@ -1,58 +0,0 @@
import { store, RoomsDispatch, RoomsSelectors } from "store";
import { WebClient } from "../WebClient";
import { NormalizeService } from "websocket";
export default class RoomService {
webClient: WebClient;
constructor(webClient) {
this.webClient = webClient;
}
clearStore() {
RoomsDispatch.clearStore();
}
joinRoom(roomInfo) {
NormalizeService.normalizeRoomInfo(roomInfo);
RoomsDispatch.joinRoom(roomInfo);
}
leaveRoom(roomId) {
RoomsDispatch.leaveRoom(roomId);
}
updateRooms(rooms) {
RoomsDispatch.updateRooms(rooms);
}
updateGames(roomId, gameList) {
const game = gameList[0];
if (!game.gameType) {
const room = RoomsSelectors.getRoom(store.getState(), roomId);
if (room) {
const { gametypeMap } = room;
NormalizeService.normalizeGameObject(game, gametypeMap);
}
}
RoomsDispatch.updateGames(roomId, gameList);
}
addMessage(roomId, message) {
NormalizeService.normalizeUserMessage(message);
RoomsDispatch.addMessage(roomId, message);
}
userJoined(roomId, user) {
RoomsDispatch.userJoined(roomId, user);
}
userLeft(roomId, name) {
RoomsDispatch.userLeft(roomId, name);
}
}