You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-26 17:03:12 +03:00
Add a separate file for types
This commit is contained in:
@@ -28,6 +28,7 @@ import MatrixEvent from '../models/event';
|
|||||||
import {EventType} from '../@types/event';
|
import {EventType} from '../@types/event';
|
||||||
import { RoomMember } from '../models/room-member';
|
import { RoomMember } from '../models/room-member';
|
||||||
import { randomString } from '../randomstring';
|
import { randomString } from '../randomstring';
|
||||||
|
import { MCallReplacesEvent, MCallAnswer, MCallOfferNegotiate, CallCapabilities } from './callEventTypes';
|
||||||
|
|
||||||
// events: hangup, error(err), replaced(call), state(state, oldState)
|
// events: hangup, error(err), replaced(call), state(state, oldState)
|
||||||
|
|
||||||
@@ -61,26 +62,6 @@ interface TurnServer {
|
|||||||
ttl?: number,
|
ttl?: number,
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CallCapabilities {
|
|
||||||
'm.call.transferee': boolean,
|
|
||||||
}
|
|
||||||
|
|
||||||
// allow camelcase as these are events type that go onto the wire
|
|
||||||
/* eslint-disable camelcase */
|
|
||||||
interface MCallReplacesTarget {
|
|
||||||
id: string;
|
|
||||||
display_name: string,
|
|
||||||
avatar_url: string,
|
|
||||||
}
|
|
||||||
|
|
||||||
interface MCallReplacesEvent {
|
|
||||||
replacement_id: string;
|
|
||||||
target_user: MCallReplacesTarget;
|
|
||||||
create_call: string;
|
|
||||||
target_room: string;
|
|
||||||
}
|
|
||||||
/* eslint-enable camelcase */
|
|
||||||
|
|
||||||
export enum CallState {
|
export enum CallState {
|
||||||
Fledgling = 'fledgling',
|
Fledgling = 'fledgling',
|
||||||
InviteSent = 'invite_sent',
|
InviteSent = 'invite_sent',
|
||||||
@@ -810,7 +791,7 @@ export class MatrixCall extends EventEmitter {
|
|||||||
// required to still be sent for backwards compat
|
// required to still be sent for backwards compat
|
||||||
type: this.peerConn.localDescription.type,
|
type: this.peerConn.localDescription.type,
|
||||||
},
|
},
|
||||||
} as any;
|
} as MCallAnswer;
|
||||||
|
|
||||||
if (this.client._supportsTransfer) {
|
if (this.client._supportsTransfer) {
|
||||||
answerContent.capabilities = {
|
answerContent.capabilities = {
|
||||||
@@ -1135,13 +1116,18 @@ export class MatrixCall extends EventEmitter {
|
|||||||
|
|
||||||
if (this.callHasEnded()) return;
|
if (this.callHasEnded()) return;
|
||||||
|
|
||||||
const keyName = this.state === CallState.CreateOffer ? 'offer' : 'description';
|
|
||||||
const eventType = this.state === CallState.CreateOffer ? EventType.CallInvite : EventType.CallNegotiate;
|
const eventType = this.state === CallState.CreateOffer ? EventType.CallInvite : EventType.CallNegotiate;
|
||||||
|
|
||||||
const content = {
|
const content = {
|
||||||
[keyName]: this.peerConn.localDescription,
|
|
||||||
lifetime: CALL_TIMEOUT_MS,
|
lifetime: CALL_TIMEOUT_MS,
|
||||||
} as any;
|
} as MCallOfferNegotiate;
|
||||||
|
|
||||||
|
// clunky because TypeScript can't folow the types through if we use an expression as the key
|
||||||
|
if (this.state === CallState.CreateOffer) {
|
||||||
|
content.offer = this.peerConn.localDescription;
|
||||||
|
} else {
|
||||||
|
content.description = this.peerConn.localDescription;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.client._supportsTransfer) {
|
if (this.client._supportsTransfer) {
|
||||||
content.capabilities = {
|
content.capabilities = {
|
||||||
|
|||||||
37
src/webrtc/callEventTypes.ts
Normal file
37
src/webrtc/callEventTypes.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
// allow camelcase as these are events type that go onto the wire
|
||||||
|
/* eslint-disable camelcase */
|
||||||
|
|
||||||
|
interface CallOfferAnswer {
|
||||||
|
type: string;
|
||||||
|
sdp: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CallCapabilities {
|
||||||
|
'm.call.transferee': boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MCallAnswer {
|
||||||
|
answer: CallOfferAnswer;
|
||||||
|
capabilities: CallCapabilities;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MCallOfferNegotiate {
|
||||||
|
offer: CallOfferAnswer;
|
||||||
|
description: CallOfferAnswer;
|
||||||
|
lifetime: number;
|
||||||
|
capabilities: CallCapabilities;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MCallReplacesTarget {
|
||||||
|
id: string;
|
||||||
|
display_name: string;
|
||||||
|
avatar_url: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MCallReplacesEvent {
|
||||||
|
replacement_id: string;
|
||||||
|
target_user: MCallReplacesTarget;
|
||||||
|
create_call: string;
|
||||||
|
target_room: string;
|
||||||
|
}
|
||||||
|
/* eslint-enable camelcase */
|
||||||
Reference in New Issue
Block a user