Getting back code in compilable fashion after huge rebase
This commit is contained in:
parent
4b72958193
commit
2e61c2ef62
@ -197,8 +197,8 @@ export class Connection implements Connection {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
sendWebrtcScreenSharingSignal(signal: any, roomId: string, userId? : string|null) {
|
public sendWebrtcScreenSharingSignal(signal: unknown, roomId: string, userId? : string|null) {
|
||||||
return this.getSocket().emit(EventMessage.WEBRTC_SCREEN_SHARING_SIGNAL, {
|
return this.socket.emit(EventMessage.WEBRTC_SCREEN_SHARING_SIGNAL, {
|
||||||
userId: userId,
|
userId: userId,
|
||||||
roomId: roomId,
|
roomId: roomId,
|
||||||
signal: signal
|
signal: signal
|
||||||
@ -213,21 +213,8 @@ export class Connection implements Connection {
|
|||||||
return this.socket.on(EventMessage.WEBRTC_SIGNAL, callback);
|
return this.socket.on(EventMessage.WEBRTC_SIGNAL, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
receiveWebrtcScreenSharingSignal(callback: Function) {
|
public receiveWebrtcScreenSharingSignal(callback: Function) {
|
||||||
return this.getSocket().on(EventMessage.WEBRTC_SCREEN_SHARING_SIGNAL, callback);
|
return this.socket.on(EventMessage.WEBRTC_SCREEN_SHARING_SIGNAL, callback);
|
||||||
}
|
|
||||||
|
|
||||||
private errorMessage(): void {
|
|
||||||
this.getSocket().on(EventMessage.MESSAGE_ERROR, (message: string) => {
|
|
||||||
console.error(EventMessage.MESSAGE_ERROR, message);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
private disconnectServer(): void {
|
|
||||||
this.getSocket().on(EventMessage.CONNECT_ERROR, () => {
|
|
||||||
this.GameManager.switchToDisconnectedScene();
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public onServerDisconnected(callback: (reason: string) => void): void {
|
public onServerDisconnected(callback: (reason: string) => void): void {
|
||||||
|
@ -18,7 +18,7 @@ import {PlayerMovement} from "./PlayerMovement";
|
|||||||
import {PlayersPositionInterpolator} from "./PlayersPositionInterpolator";
|
import {PlayersPositionInterpolator} from "./PlayersPositionInterpolator";
|
||||||
import {RemotePlayer} from "../Entity/RemotePlayer";
|
import {RemotePlayer} from "../Entity/RemotePlayer";
|
||||||
import {Queue} from 'queue-typescript';
|
import {Queue} from 'queue-typescript';
|
||||||
import {SimplePeer, UserSimplePeer} from "../../WebRtc/SimplePeer";
|
import {SimplePeer, UserSimplePeerInterface} from "../../WebRtc/SimplePeer";
|
||||||
import {ReconnectingSceneName} from "../Reconnecting/ReconnectingScene";
|
import {ReconnectingSceneName} from "../Reconnecting/ReconnectingScene";
|
||||||
import {FourOFourSceneName} from "../Reconnecting/FourOFourScene";
|
import {FourOFourSceneName} from "../Reconnecting/FourOFourScene";
|
||||||
import {loadAllLayers} from "../Entity/body_character";
|
import {loadAllLayers} from "../Entity/body_character";
|
||||||
@ -229,7 +229,7 @@ export class GameScene extends Phaser.Scene {
|
|||||||
this.simplePeer = new SimplePeer(this.connection);
|
this.simplePeer = new SimplePeer(this.connection);
|
||||||
const self = this;
|
const self = this;
|
||||||
this.simplePeer.registerPeerConnectionListener({
|
this.simplePeer.registerPeerConnectionListener({
|
||||||
onConnect(user: UserSimplePeer) {
|
onConnect(user: UserSimplePeerInterface) {
|
||||||
self.presentationModeSprite.setVisible(true);
|
self.presentationModeSprite.setVisible(true);
|
||||||
self.chatModeSprite.setVisible(true);
|
self.chatModeSprite.setVisible(true);
|
||||||
},
|
},
|
||||||
|
@ -11,6 +11,7 @@ interface MediaServiceInterface extends MediaDevices{
|
|||||||
}
|
}
|
||||||
|
|
||||||
type UpdatedLocalStreamCallback = (media: MediaStream) => void;
|
type UpdatedLocalStreamCallback = (media: MediaStream) => void;
|
||||||
|
type UpdatedScreenSharingCallback = (media: MediaStream) => void;
|
||||||
|
|
||||||
// TODO: Split MediaManager in 2 classes: MediaManagerUI (in charge of HTML) and MediaManager (singleton in charge of the camera only)
|
// TODO: Split MediaManager in 2 classes: MediaManagerUI (in charge of HTML) and MediaManager (singleton in charge of the camera only)
|
||||||
// TODO: verify that microphone event listeners are not triggered plenty of time NOW (since MediaManager is created many times!!!!)
|
// TODO: verify that microphone event listeners are not triggered plenty of time NOW (since MediaManager is created many times!!!!)
|
||||||
@ -31,11 +32,10 @@ export class MediaManager {
|
|||||||
video: videoConstraint
|
video: videoConstraint
|
||||||
};
|
};
|
||||||
updatedLocalStreamCallBacks : Set<UpdatedLocalStreamCallback> = new Set<UpdatedLocalStreamCallback>();
|
updatedLocalStreamCallBacks : Set<UpdatedLocalStreamCallback> = new Set<UpdatedLocalStreamCallback>();
|
||||||
// TODO: updatedScreenSharingCallBack should have same signature as updatedLocalStreamCallBacks
|
updatedScreenSharingCallBacks : Set<UpdatedScreenSharingCallback> = new Set<UpdatedScreenSharingCallback>();
|
||||||
updatedScreenSharingCallBack : Function;
|
|
||||||
|
|
||||||
constructor(updatedScreenSharingCallBack : Function) {
|
|
||||||
this.updatedScreenSharingCallBack = updatedScreenSharingCallBack;
|
constructor() {
|
||||||
|
|
||||||
this.myCamVideo = this.getElementByIdOrFail<HTMLVideoElement>('myCamVideo');
|
this.myCamVideo = this.getElementByIdOrFail<HTMLVideoElement>('myCamVideo');
|
||||||
this.webrtcInAudio = this.getElementByIdOrFail<HTMLAudioElement>('audio-webrtc-in');
|
this.webrtcInAudio = this.getElementByIdOrFail<HTMLAudioElement>('audio-webrtc-in');
|
||||||
@ -69,14 +69,14 @@ export class MediaManager {
|
|||||||
//update tracking
|
//update tracking
|
||||||
});
|
});
|
||||||
|
|
||||||
this.monitorClose = document.getElementById('monitor-close');
|
this.monitorClose = this.getElementByIdOrFail<HTMLImageElement>('monitor-close');
|
||||||
this.monitorClose.style.display = "block";
|
this.monitorClose.style.display = "block";
|
||||||
this.monitorClose.addEventListener('click', (e: any) => {
|
this.monitorClose.addEventListener('click', (e: any) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this.enabledMonitor();
|
this.enabledMonitor();
|
||||||
//update tracking
|
//update tracking
|
||||||
});
|
});
|
||||||
this.monitor = document.getElementById('monitor');
|
this.monitor = this.getElementByIdOrFail<HTMLImageElement>('monitor');
|
||||||
this.monitor.style.display = "none";
|
this.monitor.style.display = "none";
|
||||||
this.monitor.addEventListener('click', (e: any) => {
|
this.monitor.addEventListener('click', (e: any) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@ -90,6 +90,11 @@ export class MediaManager {
|
|||||||
this.updatedLocalStreamCallBacks.add(callback);
|
this.updatedLocalStreamCallBacks.add(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onUpdateScreenSharing(callback: UpdatedScreenSharingCallback): void {
|
||||||
|
|
||||||
|
this.updatedScreenSharingCallBacks.add(callback);
|
||||||
|
}
|
||||||
|
|
||||||
removeUpdateLocalStreamEventListener(callback: UpdatedLocalStreamCallback): void {
|
removeUpdateLocalStreamEventListener(callback: UpdatedLocalStreamCallback): void {
|
||||||
this.updatedLocalStreamCallBacks.delete(callback);
|
this.updatedLocalStreamCallBacks.delete(callback);
|
||||||
}
|
}
|
||||||
@ -100,6 +105,12 @@ export class MediaManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private triggerUpdatedScreenSharingCallbacks(stream: MediaStream): void {
|
||||||
|
for (const callback of this.updatedScreenSharingCallBacks) {
|
||||||
|
callback(stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
activeVisio(){
|
activeVisio(){
|
||||||
const gameOverlay = this.getElementByIdOrFail('game-overlay');
|
const gameOverlay = this.getElementByIdOrFail('game-overlay');
|
||||||
gameOverlay.classList.add('active');
|
gameOverlay.classList.add('active');
|
||||||
@ -156,7 +167,7 @@ export class MediaManager {
|
|||||||
this.monitorClose.style.display = "none";
|
this.monitorClose.style.display = "none";
|
||||||
this.monitor.style.display = "block";
|
this.monitor.style.display = "block";
|
||||||
this.getScreenMedia().then((stream) => {
|
this.getScreenMedia().then((stream) => {
|
||||||
this.updatedScreenSharingCallBack(stream);
|
this.triggerUpdatedScreenSharingCallbacks(stream);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,7 +179,7 @@ export class MediaManager {
|
|||||||
});
|
});
|
||||||
this.localScreenCapture = null;
|
this.localScreenCapture = null;
|
||||||
this.getCamera().then((stream) => {
|
this.getCamera().then((stream) => {
|
||||||
this.updatedScreenSharingCallBack(stream);
|
this.triggerUpdatedScreenSharingCallbacks(stream);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ export interface UserSimplePeerInterface{
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface PeerConnectionListener {
|
export interface PeerConnectionListener {
|
||||||
onConnect(user: UserSimplePeer): void;
|
onConnect(user: UserSimplePeerInterface): void;
|
||||||
|
|
||||||
onDisconnect(userId: string): void;
|
onDisconnect(userId: string): void;
|
||||||
}
|
}
|
||||||
@ -138,7 +138,7 @@ export class SimplePeer {
|
|||||||
mediaManager.addActiveVideo(user.userId, name);
|
mediaManager.addActiveVideo(user.userId, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
const peerOption : SimplePeerNamespace.Instance = new Peer({
|
const peer : SimplePeerNamespace.Instance = new Peer({
|
||||||
initiator: user.initiator ? user.initiator : false,
|
initiator: user.initiator ? user.initiator : false,
|
||||||
reconnectTimer: 10000,
|
reconnectTimer: 10000,
|
||||||
config: {
|
config: {
|
||||||
@ -153,9 +153,7 @@ export class SimplePeer {
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
console.log("peerOption", peerOption);
|
|
||||||
let peer : SimplePeerNamespace.Instance = new Peer(peerOption);
|
|
||||||
if(screenSharing){
|
if(screenSharing){
|
||||||
this.PeerScreenSharingConnectionArray.set(user.userId, peer);
|
this.PeerScreenSharingConnectionArray.set(user.userId, peer);
|
||||||
}else {
|
}else {
|
||||||
@ -434,11 +432,12 @@ export class SimplePeer {
|
|||||||
|
|
||||||
//this.Connection.sendWebrtcScreenSharingStart(this.WebRtcRoomId);
|
//this.Connection.sendWebrtcScreenSharingStart(this.WebRtcRoomId);
|
||||||
|
|
||||||
if(!this.Connection.userId){
|
const userId = this.Connection.getUserId();
|
||||||
|
if(!userId){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let screenSharingUser: UserSimplePeerInterface = {
|
let screenSharingUser: UserSimplePeerInterface = {
|
||||||
userId: this.Connection.userId,
|
userId,
|
||||||
initiator: true
|
initiator: true
|
||||||
};
|
};
|
||||||
let PeerConnectionScreenSharing = this.createPeerConnection(screenSharingUser, true);
|
let PeerConnectionScreenSharing = this.createPeerConnection(screenSharingUser, true);
|
||||||
@ -454,16 +453,17 @@ export class SimplePeer {
|
|||||||
}
|
}
|
||||||
mediaManager.addStreamRemoteScreenSharing(screenSharingUser.userId, mediaManager.localScreenCapture);
|
mediaManager.addStreamRemoteScreenSharing(screenSharingUser.userId, mediaManager.localScreenCapture);
|
||||||
} else {
|
} else {
|
||||||
if (!this.Connection.userId || !this.PeerScreenSharingConnectionArray.has(this.Connection.userId)) {
|
const userId = this.Connection.getUserId();
|
||||||
|
if (!userId || !this.PeerScreenSharingConnectionArray.has(userId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let PeerConnectionScreenSharing = this.PeerScreenSharingConnectionArray.get(this.Connection.userId);
|
let PeerConnectionScreenSharing = this.PeerScreenSharingConnectionArray.get(userId);
|
||||||
console.log("updatedScreenSharing => destroy", PeerConnectionScreenSharing);
|
console.log("updatedScreenSharing => destroy", PeerConnectionScreenSharing);
|
||||||
if (!PeerConnectionScreenSharing) {
|
if (!PeerConnectionScreenSharing) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PeerConnectionScreenSharing.destroy();
|
PeerConnectionScreenSharing.destroy();
|
||||||
this.PeerScreenSharingConnectionArray.delete(this.Connection.userId);
|
this.PeerScreenSharingConnectionArray.delete(userId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user