mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-12-27 22:18:52 +00:00
Start to implement WebSockets route system
This commit is contained in:
parent
92486a01ac
commit
d4b624e519
@ -19,14 +19,14 @@ interface PendingRequests {
|
||||
token: string
|
||||
}
|
||||
|
||||
interface ActiveClient {
|
||||
export interface ActiveClient {
|
||||
socketID: string,
|
||||
clientID: number,
|
||||
userID: number,
|
||||
ws: ws
|
||||
}
|
||||
|
||||
interface WsMessage {
|
||||
export interface WsMessage {
|
||||
id: string,
|
||||
title: string,
|
||||
data: any
|
||||
|
17
src/controllers/UserWebSocketRoutes.ts
Normal file
17
src/controllers/UserWebSocketRoutes.ts
Normal file
@ -0,0 +1,17 @@
|
||||
/**
|
||||
* User Websocket requests route
|
||||
*
|
||||
* Note : this implementation requires the
|
||||
* user to be signed in to perform requests
|
||||
*
|
||||
* @author Pierre Hubert
|
||||
*/
|
||||
|
||||
import { UserWebSocketRequestsHandler } from "../entities/WebSocketRequestHandler";
|
||||
|
||||
export interface UserWebSocketRoute {
|
||||
title: string,
|
||||
handler: (h: UserWebSocketRequestsHandler) => Promise<void>
|
||||
}
|
||||
|
||||
export const UserWebSocketRoutes: UserWebSocketRoute[] = []
|
37
src/entities/WebSocketRequestHandler.ts
Normal file
37
src/entities/WebSocketRequestHandler.ts
Normal file
@ -0,0 +1,37 @@
|
||||
/**
|
||||
* User Web Sockets requests handler implementation
|
||||
*
|
||||
* @author Pierre Hubert
|
||||
*/
|
||||
|
||||
import { BaseRequestsHandler } from "./BaseRequestsHandler";
|
||||
import { ActiveClient, WsMessage } from "../controllers/UserWebSocketController";
|
||||
|
||||
export class UserWebSocketRequestsHandler extends BaseRequestsHandler {
|
||||
|
||||
constructor(private wsClient: ActiveClient, private req: WsMessage) {
|
||||
super();
|
||||
}
|
||||
|
||||
protected get userID(): number {
|
||||
return this.wsClient.userID;
|
||||
}
|
||||
|
||||
|
||||
protected getPostParam(name: string) {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
public hasPostParameter(name: string): boolean {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
public error(code: number, message: string): void {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
public success(message: string): void {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
public send(data: any): void {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user