[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/devforth/adminforth/main/adminforth/servers/common.ts [Back]  [Original]

import { AdminUserAuthorizationResult, IWebSocketClient } from "../types/Back.js";
import { AdminUser } from "../types/Common.js";


export class WebSocketClient implements IWebSocketClient {
  id: string;
  clientId?: string;
  lastPing: number;
  topics: Set;
  adminUser: AdminUser;

  authorize: () => Promise;
  send: (message: string) => void;
  close: () => void;
  onMessage: (handler: (message: string) => void) => void;
  onClose: (handler: () => void) => void;

  constructor({ id, clientId, authorize, send, close, onMessage, onClose, adminUser }) {
    this.id = id;
    this.clientId = clientId;
    this.authorize = authorize;
    this.send = send;
    this.close = close;
    this.onMessage = onMessage;
    this.onClose = onClose;

    this.lastPing = Date.now();
    this.topics = new Set();
    this.adminUser = adminUser;
  }
}

Web Proxy Viewer  |  New URL  |  Original Page