blob: f85ea5ecd65b769555663b097f2d1a6330c01fca [file] [log] [blame]
Charlie6ddaefe2022-11-01 18:36:29 -04001/*
2 * Copyright (C) 2022 Savoir-faire Linux Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License as
6 * published by the Free Software Foundation; either version 3 of the
7 * License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Affero General Public License for more details.
13 *
14 * You should have received a copy of the GNU Affero General Public
15 * License along with this program. If not, see
16 * <https://www.gnu.org/licenses/>.
17 */
Issam E. Maghni0432cb72022-11-12 06:09:26 +000018import { WebSocketMessageType } from '../enums/websocket-message-type.js';
idillon18283ac2023-01-07 12:06:42 -050019import { IConversationRequest } from './conversation.js';
simonf929a362022-11-18 16:53:45 -050020import {
idillon255682e2023-02-06 13:25:26 -050021 CallExit,
22 CallInvite,
23 CallJoin,
idillon3e378fd2022-12-23 11:48:12 -050024 ComposingStatus,
simonf929a362022-11-18 16:53:45 -050025 ConversationMessage,
26 ConversationView,
Misha Krieger-Raynauld20cf1c82022-11-23 20:26:50 -050027 WebRtcIceCandidate,
simonf929a362022-11-18 16:53:45 -050028 WebRtcSdp,
idillon255682e2023-02-06 13:25:26 -050029 WithReceiver,
30 WithSender,
simonf929a362022-11-18 16:53:45 -050031} from './websocket-interfaces.js';
Charlie6ddaefe2022-11-01 18:36:29 -040032
Issam E. Maghni0432cb72022-11-12 06:09:26 +000033export interface WebSocketMessageTable {
idillonbad51972023-01-18 17:00:38 -050034 [WebSocketMessageType.ComposingStatus]: ComposingStatus;
Issam E. Maghni0432cb72022-11-12 06:09:26 +000035 [WebSocketMessageType.ConversationMessage]: ConversationMessage;
idillon18283ac2023-01-07 12:06:42 -050036 [WebSocketMessageType.ConversationRequest]: IConversationRequest;
Issam E. Maghni0432cb72022-11-12 06:09:26 +000037 [WebSocketMessageType.ConversationView]: ConversationView;
idillon255682e2023-02-06 13:25:26 -050038
39 // calls (in the order they should be sent)
40 [WebSocketMessageType.sendCallInvite]: CallInvite;
41 [WebSocketMessageType.onCallInvite]: CallInvite & WithSender;
42 [WebSocketMessageType.sendCallExit]: CallExit; // can be sent any time after invite
43 [WebSocketMessageType.onCallExit]: CallExit & WithSender;
44 [WebSocketMessageType.sendCallJoin]: CallJoin;
45 [WebSocketMessageType.onCallJoin]: CallJoin & WithSender;
46 [WebSocketMessageType.sendWebRtcOffer]: WebRtcSdp & WithReceiver;
47 [WebSocketMessageType.onWebRtcOffer]: WebRtcSdp & WithSender;
48 [WebSocketMessageType.sendWebRtcAnswer]: WebRtcSdp & WithReceiver;
49 [WebSocketMessageType.onWebRtcAnswer]: WebRtcSdp & WithSender;
50 [WebSocketMessageType.sendWebRtcIceCandidate]: WebRtcIceCandidate & WithReceiver;
51 [WebSocketMessageType.onWebRtcIceCandidate]: WebRtcIceCandidate & WithSender;
Issam E. Maghni0432cb72022-11-12 06:09:26 +000052}
53
54export interface WebSocketMessage<T extends WebSocketMessageType> {
55 type: T;
56 data: WebSocketMessageTable[T];
Charlie6ddaefe2022-11-01 18:36:29 -040057}