Created a PeerStatus type instead of "connecting" | "connected" | "error" | "closed"
This commit is contained in:
parent
b59cbcac4c
commit
5ed61012f0
@ -2,7 +2,7 @@ import type * as SimplePeerNamespace from "simple-peer";
|
|||||||
import {mediaManager} from "./MediaManager";
|
import {mediaManager} from "./MediaManager";
|
||||||
import {STUN_SERVER, TURN_PASSWORD, TURN_SERVER, TURN_USER} from "../Enum/EnvironmentVariable";
|
import {STUN_SERVER, TURN_PASSWORD, TURN_SERVER, TURN_USER} from "../Enum/EnvironmentVariable";
|
||||||
import type {RoomConnection} from "../Connexion/RoomConnection";
|
import type {RoomConnection} from "../Connexion/RoomConnection";
|
||||||
import {MESSAGE_TYPE_CONSTRAINT} from "./VideoPeer";
|
import {MESSAGE_TYPE_CONSTRAINT, PeerStatus} from "./VideoPeer";
|
||||||
import type {UserSimplePeerInterface} from "./SimplePeer";
|
import type {UserSimplePeerInterface} from "./SimplePeer";
|
||||||
import {Readable, readable, writable, Writable} from "svelte/store";
|
import {Readable, readable, writable, Writable} from "svelte/store";
|
||||||
import {videoFocusStore} from "../Stores/VideoFocusStore";
|
import {videoFocusStore} from "../Stores/VideoFocusStore";
|
||||||
@ -22,7 +22,7 @@ export class ScreenSharingPeer extends Peer {
|
|||||||
public readonly userId: number;
|
public readonly userId: number;
|
||||||
public readonly uniqueId: string;
|
public readonly uniqueId: string;
|
||||||
public readonly streamStore: Readable<MediaStream | null>;
|
public readonly streamStore: Readable<MediaStream | null>;
|
||||||
public readonly statusStore: Readable<"connecting" | "connected" | "error" | "closed">;
|
public readonly statusStore: Readable<PeerStatus>;
|
||||||
|
|
||||||
constructor(user: UserSimplePeerInterface, initiator: boolean, public readonly userName: string, private connection: RoomConnection, stream: MediaStream | null) {
|
constructor(user: UserSimplePeerInterface, initiator: boolean, public readonly userName: string, private connection: RoomConnection, stream: MediaStream | null) {
|
||||||
super({
|
super({
|
||||||
@ -71,7 +71,7 @@ export class ScreenSharingPeer extends Peer {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
this.statusStore = readable<"connecting" | "connected" | "error" | "closed">("connecting", (set) => {
|
this.statusStore = readable<PeerStatus>("connecting", (set) => {
|
||||||
const onConnect = () => {
|
const onConnect = () => {
|
||||||
set('connected');
|
set('connected');
|
||||||
};
|
};
|
||||||
|
@ -12,6 +12,8 @@ import {discussionManager} from "./DiscussionManager";
|
|||||||
|
|
||||||
const Peer: SimplePeerNamespace.SimplePeer = require('simple-peer');
|
const Peer: SimplePeerNamespace.SimplePeer = require('simple-peer');
|
||||||
|
|
||||||
|
export type PeerStatus = "connecting" | "connected" | "error" | "closed";
|
||||||
|
|
||||||
export const MESSAGE_TYPE_CONSTRAINT = 'constraint';
|
export const MESSAGE_TYPE_CONSTRAINT = 'constraint';
|
||||||
export const MESSAGE_TYPE_MESSAGE = 'message';
|
export const MESSAGE_TYPE_MESSAGE = 'message';
|
||||||
export const MESSAGE_TYPE_BLOCKED = 'blocked';
|
export const MESSAGE_TYPE_BLOCKED = 'blocked';
|
||||||
@ -29,7 +31,7 @@ export class VideoPeer extends Peer {
|
|||||||
private onBlockSubscribe: Subscription;
|
private onBlockSubscribe: Subscription;
|
||||||
private onUnBlockSubscribe: Subscription;
|
private onUnBlockSubscribe: Subscription;
|
||||||
public readonly streamStore: Readable<MediaStream | null>;
|
public readonly streamStore: Readable<MediaStream | null>;
|
||||||
public readonly statusStore: Readable<"connecting" | "connected" | "error" | "closed">;
|
public readonly statusStore: Readable<PeerStatus>;
|
||||||
public readonly constraintsStore: Readable<MediaStreamConstraints|null>;
|
public readonly constraintsStore: Readable<MediaStreamConstraints|null>;
|
||||||
|
|
||||||
constructor(public user: UserSimplePeerInterface, initiator: boolean, public readonly userName: string, private connection: RoomConnection, localStream: MediaStream | null) {
|
constructor(public user: UserSimplePeerInterface, initiator: boolean, public readonly userName: string, private connection: RoomConnection, localStream: MediaStream | null) {
|
||||||
@ -92,7 +94,7 @@ export class VideoPeer extends Peer {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
this.statusStore = readable<"connecting" | "connected" | "error" | "closed">("connecting", (set) => {
|
this.statusStore = readable<PeerStatus>("connecting", (set) => {
|
||||||
const onConnect = () => {
|
const onConnect = () => {
|
||||||
set('connected');
|
set('connected');
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user