blob: f85ea5ecd65b769555663b097f2d1a6330c01fca [file] [log] [blame]
/*
* Copyright (C) 2022 Savoir-faire Linux Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this program. If not, see
* <https://www.gnu.org/licenses/>.
*/
import { WebSocketMessageType } from '../enums/websocket-message-type.js';
import { IConversationRequest } from './conversation.js';
import {
CallExit,
CallInvite,
CallJoin,
ComposingStatus,
ConversationMessage,
ConversationView,
WebRtcIceCandidate,
WebRtcSdp,
WithReceiver,
WithSender,
} from './websocket-interfaces.js';
export interface WebSocketMessageTable {
[WebSocketMessageType.ComposingStatus]: ComposingStatus;
[WebSocketMessageType.ConversationMessage]: ConversationMessage;
[WebSocketMessageType.ConversationRequest]: IConversationRequest;
[WebSocketMessageType.ConversationView]: ConversationView;
// calls (in the order they should be sent)
[WebSocketMessageType.sendCallInvite]: CallInvite;
[WebSocketMessageType.onCallInvite]: CallInvite & WithSender;
[WebSocketMessageType.sendCallExit]: CallExit; // can be sent any time after invite
[WebSocketMessageType.onCallExit]: CallExit & WithSender;
[WebSocketMessageType.sendCallJoin]: CallJoin;
[WebSocketMessageType.onCallJoin]: CallJoin & WithSender;
[WebSocketMessageType.sendWebRtcOffer]: WebRtcSdp & WithReceiver;
[WebSocketMessageType.onWebRtcOffer]: WebRtcSdp & WithSender;
[WebSocketMessageType.sendWebRtcAnswer]: WebRtcSdp & WithReceiver;
[WebSocketMessageType.onWebRtcAnswer]: WebRtcSdp & WithSender;
[WebSocketMessageType.sendWebRtcIceCandidate]: WebRtcIceCandidate & WithReceiver;
[WebSocketMessageType.onWebRtcIceCandidate]: WebRtcIceCandidate & WithSender;
}
export interface WebSocketMessage<T extends WebSocketMessageType> {
type: T;
data: WebSocketMessageTable[T];
}