Обработка END_CALL_BECAUSE_BUSY и END_CALL_BECAUSE_PEER_DISCONNECTED
This commit is contained in:
@@ -8,6 +8,8 @@ import { usePacket } from "../ProtocolProvider/usePacket";
|
|||||||
import { usePublicKey } from "../AccountProvider/usePublicKey";
|
import { usePublicKey } from "../AccountProvider/usePublicKey";
|
||||||
import { PacketWebRTC, WebRTCSignalType } from "../ProtocolProvider/protocol/packets/packet.webrtc";
|
import { PacketWebRTC, WebRTCSignalType } from "../ProtocolProvider/protocol/packets/packet.webrtc";
|
||||||
import { PacketIceServers } from "../ProtocolProvider/protocol/packets/packet.ice.servers";
|
import { PacketIceServers } from "../ProtocolProvider/protocol/packets/packet.ice.servers";
|
||||||
|
import { modals } from "@mantine/modals";
|
||||||
|
import { Button, Flex, Text } from "@mantine/core";
|
||||||
|
|
||||||
|
|
||||||
export interface CallContextValue {
|
export interface CallContextValue {
|
||||||
@@ -165,6 +167,46 @@ export function CallProvider(props : CallProviderProps) {
|
|||||||
|
|
||||||
usePacket(26, async (packet: PacketSignalPeer) => {
|
usePacket(26, async (packet: PacketSignalPeer) => {
|
||||||
const signalType = packet.getSignalType();
|
const signalType = packet.getSignalType();
|
||||||
|
if(signalType == SignalType.END_CALL_BECAUSE_BUSY) {
|
||||||
|
modals.open({
|
||||||
|
title: 'Busy',
|
||||||
|
centered: true,
|
||||||
|
children: (
|
||||||
|
<>
|
||||||
|
<Text size="sm">
|
||||||
|
Line is busy, the user is currently on another call. Please try again later.
|
||||||
|
</Text>
|
||||||
|
<Flex align={'center'} justify={'flex-end'}>
|
||||||
|
<Button color={'red'} variant={'subtle'} onClick={() => modals.closeAll()} mt="md">
|
||||||
|
Close
|
||||||
|
</Button>
|
||||||
|
</Flex>
|
||||||
|
</>
|
||||||
|
),
|
||||||
|
withCloseButton: false
|
||||||
|
});
|
||||||
|
end();
|
||||||
|
}
|
||||||
|
if(signalType == SignalType.END_CALL_BECAUSE_PEER_DISCONNECTED) {
|
||||||
|
modals.open({
|
||||||
|
title: 'Connection lost',
|
||||||
|
centered: true,
|
||||||
|
children: (
|
||||||
|
<>
|
||||||
|
<Text size="sm">
|
||||||
|
The connection with the user was lost. The call has ended.
|
||||||
|
</Text>
|
||||||
|
<Flex align={'center'} justify={'flex-end'}>
|
||||||
|
<Button color={'red'} variant={'subtle'} onClick={() => modals.closeAll()} mt="md">
|
||||||
|
Close
|
||||||
|
</Button>
|
||||||
|
</Flex>
|
||||||
|
</>
|
||||||
|
),
|
||||||
|
withCloseButton: false
|
||||||
|
});
|
||||||
|
end();
|
||||||
|
}
|
||||||
if(activeCall){
|
if(activeCall){
|
||||||
/**
|
/**
|
||||||
* У нас уже есть активный звонок, игнорируем все сигналы, кроме сигналов от текущего звонка
|
* У нас уже есть активный звонок, игнорируем все сигналы, кроме сигналов от текущего звонка
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ export enum SignalType {
|
|||||||
KEY_EXCHANGE = 1,
|
KEY_EXCHANGE = 1,
|
||||||
ACTIVE_CALL = 2,
|
ACTIVE_CALL = 2,
|
||||||
END_CALL = 3,
|
END_CALL = 3,
|
||||||
CREATE_ROOM = 4
|
CREATE_ROOM = 4,
|
||||||
|
END_CALL_BECAUSE_PEER_DISCONNECTED = 5,
|
||||||
|
END_CALL_BECAUSE_BUSY = 6
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,6 +42,9 @@ export class PacketSignalPeer extends Packet {
|
|||||||
|
|
||||||
public _receive(stream: Stream): void {
|
public _receive(stream: Stream): void {
|
||||||
this.signalType = stream.readInt8();
|
this.signalType = stream.readInt8();
|
||||||
|
if(this.signalType == SignalType.END_CALL_BECAUSE_BUSY || this.signalType == SignalType.END_CALL_BECAUSE_PEER_DISCONNECTED){
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.src = stream.readString();
|
this.src = stream.readString();
|
||||||
this.dst = stream.readString();
|
this.dst = stream.readString();
|
||||||
if(this.signalType == SignalType.KEY_EXCHANGE){
|
if(this.signalType == SignalType.KEY_EXCHANGE){
|
||||||
@@ -54,6 +59,9 @@ export class PacketSignalPeer extends Packet {
|
|||||||
const stream = new Stream();
|
const stream = new Stream();
|
||||||
stream.writeInt16(this.getPacketId());
|
stream.writeInt16(this.getPacketId());
|
||||||
stream.writeInt8(this.signalType);
|
stream.writeInt8(this.signalType);
|
||||||
|
if(this.signalType == SignalType.END_CALL_BECAUSE_BUSY || this.signalType == SignalType.END_CALL_BECAUSE_PEER_DISCONNECTED){
|
||||||
|
return stream;
|
||||||
|
}
|
||||||
stream.writeString(this.src);
|
stream.writeString(this.src);
|
||||||
stream.writeString(this.dst);
|
stream.writeString(this.dst);
|
||||||
if(this.signalType == SignalType.KEY_EXCHANGE){
|
if(this.signalType == SignalType.KEY_EXCHANGE){
|
||||||
|
|||||||
Reference in New Issue
Block a user