| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- import { Container } from 'unstated';
- import io from 'socket.io-client';
- /**
- * Service container related to options for WebSocket
- * @extends {Container} unstated Container
- */
- export default class WebsocketContainer extends Container {
- constructor(appContainer) {
- super();
- this.appContainer = appContainer;
- this.appContainer.registerContainer(this);
- this.socket = io();
- this.socketClientId = Math.floor(Math.random() * 100000);
- this.state = {
- };
- }
- /**
- * Workaround for the mangling in production build to break constructor.name
- */
- static getClassName() {
- return 'WebsocketContainer';
- }
- getWebSocket() {
- return this.socket;
- }
- getSocketClientId() {
- return this.socketClientId;
- }
- }
|