make sure we subscribe to stores after estabilishing connection
This commit is contained in:
parent
5857c938d1
commit
2b15faf4e8
@ -562,7 +562,6 @@ export class RoomConnection implements RoomConnection {
|
|||||||
outlineColor: color,
|
outlineColor: color,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const bytes = ClientToServerMessageTsProto.encode({
|
const bytes = ClientToServerMessageTsProto.encode({
|
||||||
message: {
|
message: {
|
||||||
$case: "setPlayerDetailsMessage",
|
$case: "setPlayerDetailsMessage",
|
||||||
|
@ -173,17 +173,17 @@ export class GameScene extends DirtyScene {
|
|||||||
// A promise that will resolve when the "create" method is called (signaling loading is ended)
|
// A promise that will resolve when the "create" method is called (signaling loading is ended)
|
||||||
private createPromiseDeferred: Deferred<void>;
|
private createPromiseDeferred: Deferred<void>;
|
||||||
private iframeSubscriptionList!: Array<Subscription>;
|
private iframeSubscriptionList!: Array<Subscription>;
|
||||||
private peerStoreUnsubscribe!: Unsubscriber;
|
private peerStoreUnsubscriber!: Unsubscriber;
|
||||||
private emoteUnsubscribe!: Unsubscriber;
|
private emoteUnsubscriber!: Unsubscriber;
|
||||||
private emoteMenuUnsubscribe!: Unsubscriber;
|
private emoteMenuUnsubscriber!: Unsubscriber;
|
||||||
|
|
||||||
private localVolumeStoreUnsubscriber: Unsubscriber | undefined;
|
private localVolumeStoreUnsubscriber: Unsubscriber | undefined;
|
||||||
private followUsersColorStoreUnsubscribe!: Unsubscriber;
|
private followUsersColorStoreUnsubscriber!: Unsubscriber;
|
||||||
private userIsJitsiDominantSpeakerStoreUnsubscriber!: Unsubscriber;
|
private userIsJitsiDominantSpeakerStoreUnsubscriber!: Unsubscriber;
|
||||||
private jitsiParticipantsCountStoreUnsubscriber!: Unsubscriber;
|
private jitsiParticipantsCountStoreUnsubscriber!: Unsubscriber;
|
||||||
private availabilityStatusStoreUnsubscriber!: Unsubscriber;
|
private availabilityStatusStoreUnsubscriber!: Unsubscriber;
|
||||||
|
|
||||||
private biggestAvailableAreaStoreUnsubscribe!: () => void;
|
private biggestAvailableAreaStoreUnsubscriber!: () => void;
|
||||||
MapUrlFile: string;
|
MapUrlFile: string;
|
||||||
roomUrl: string;
|
roomUrl: string;
|
||||||
|
|
||||||
@ -644,11 +644,6 @@ export class GameScene extends DirtyScene {
|
|||||||
|
|
||||||
this.reposition();
|
this.reposition();
|
||||||
|
|
||||||
// From now, this game scene will be notified of reposition events
|
|
||||||
this.biggestAvailableAreaStoreUnsubscribe = biggestAvailableAreaStore.subscribe((box) =>
|
|
||||||
this.cameraManager.updateCameraOffset(box)
|
|
||||||
);
|
|
||||||
|
|
||||||
new GameMapPropertiesListener(this, this.gameMap).register();
|
new GameMapPropertiesListener(this, this.gameMap).register();
|
||||||
|
|
||||||
if (!this.room.isDisconnected()) {
|
if (!this.room.isDisconnected()) {
|
||||||
@ -656,80 +651,6 @@ export class GameScene extends DirtyScene {
|
|||||||
this.connect();
|
this.connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
const talkIconVolumeTreshold = 10;
|
|
||||||
let oldPeersNumber = 0;
|
|
||||||
this.peerStoreUnsubscribe = peerStore.subscribe((peers) => {
|
|
||||||
const newPeerNumber = peers.size;
|
|
||||||
if (newPeerNumber > oldPeersNumber) {
|
|
||||||
this.playSound("audio-webrtc-in");
|
|
||||||
} else if (newPeerNumber < oldPeersNumber) {
|
|
||||||
this.playSound("audio-webrtc-out");
|
|
||||||
}
|
|
||||||
if (newPeerNumber > 0) {
|
|
||||||
if (!this.localVolumeStoreUnsubscriber) {
|
|
||||||
this.localVolumeStoreUnsubscriber = localVolumeStore.subscribe((volume) => {
|
|
||||||
if (volume === undefined) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.tryChangeShowVoiceIndicatorState(volume > talkIconVolumeTreshold);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.CurrentPlayer.showTalkIcon(false, true);
|
|
||||||
this.connection?.emitPlayerShowVoiceIndicator(false);
|
|
||||||
this.showVoiceIndicatorChangeMessageSent = false;
|
|
||||||
this.MapPlayersByKey.forEach((remotePlayer) => remotePlayer.showTalkIcon(false, true));
|
|
||||||
if (this.localVolumeStoreUnsubscriber) {
|
|
||||||
this.localVolumeStoreUnsubscriber();
|
|
||||||
this.localVolumeStoreUnsubscriber = undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
oldPeersNumber = peers.size;
|
|
||||||
});
|
|
||||||
|
|
||||||
this.userIsJitsiDominantSpeakerStoreUnsubscriber = userIsJitsiDominantSpeakerStore.subscribe(
|
|
||||||
(dominantSpeaker) => {
|
|
||||||
this.jitsiDominantSpeaker = dominantSpeaker;
|
|
||||||
this.tryChangeShowVoiceIndicatorState(this.jitsiDominantSpeaker && this.jitsiParticipantsCount > 1);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
this.jitsiParticipantsCountStoreUnsubscriber = jitsiParticipantsCountStore.subscribe((participantsCount) => {
|
|
||||||
this.jitsiParticipantsCount = participantsCount;
|
|
||||||
this.tryChangeShowVoiceIndicatorState(this.jitsiDominantSpeaker && this.jitsiParticipantsCount > 1);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.availabilityStatusStoreUnsubscriber = availabilityStatusStore.subscribe((status) => {
|
|
||||||
this.connection?.emitPlayerStatusChange(status);
|
|
||||||
this.CurrentPlayer.setStatus(status);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.emoteUnsubscribe = emoteStore.subscribe((emote) => {
|
|
||||||
if (emote) {
|
|
||||||
this.CurrentPlayer?.playEmote(emote.url);
|
|
||||||
this.connection?.emitEmoteEvent(emote.url);
|
|
||||||
emoteStore.set(null);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
this.emoteMenuUnsubscribe = emoteMenuStore.subscribe((emoteMenu) => {
|
|
||||||
if (emoteMenu) {
|
|
||||||
this.userInputManager.disableControls();
|
|
||||||
} else {
|
|
||||||
this.userInputManager.restoreControls();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
this.followUsersColorStoreUnsubscribe = followUsersColorStore.subscribe((color) => {
|
|
||||||
if (color !== undefined) {
|
|
||||||
this.CurrentPlayer.setFollowOutlineColor(color);
|
|
||||||
this.connection?.emitPlayerOutlineColor(color);
|
|
||||||
} else {
|
|
||||||
this.CurrentPlayer.removeFollowOutlineColor();
|
|
||||||
this.connection?.emitPlayerOutlineColor(null);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Promise.all([
|
Promise.all([
|
||||||
this.connectionAnswerPromiseDeferred.promise as Promise<unknown>,
|
this.connectionAnswerPromiseDeferred.promise as Promise<unknown>,
|
||||||
...scriptPromises,
|
...scriptPromises,
|
||||||
@ -771,6 +692,8 @@ export class GameScene extends DirtyScene {
|
|||||||
.then((onConnect: OnConnectInterface) => {
|
.then((onConnect: OnConnectInterface) => {
|
||||||
this.connection = onConnect.connection;
|
this.connection = onConnect.connection;
|
||||||
|
|
||||||
|
this.subscribeToStores();
|
||||||
|
|
||||||
lazyLoadPlayerCharacterTextures(this.superLoad, onConnect.room.characterLayers)
|
lazyLoadPlayerCharacterTextures(this.superLoad, onConnect.room.characterLayers)
|
||||||
.then((layers) => {
|
.then((layers) => {
|
||||||
this.currentPlayerTexturesResolve(layers);
|
this.currentPlayerTexturesResolve(layers);
|
||||||
@ -953,6 +876,87 @@ export class GameScene extends DirtyScene {
|
|||||||
.catch((e) => console.error(e));
|
.catch((e) => console.error(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private subscribeToStores(): void {
|
||||||
|
this.userIsJitsiDominantSpeakerStoreUnsubscriber = userIsJitsiDominantSpeakerStore.subscribe(
|
||||||
|
(dominantSpeaker) => {
|
||||||
|
this.jitsiDominantSpeaker = dominantSpeaker;
|
||||||
|
this.tryChangeShowVoiceIndicatorState(this.jitsiDominantSpeaker && this.jitsiParticipantsCount > 1);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
this.jitsiParticipantsCountStoreUnsubscriber = jitsiParticipantsCountStore.subscribe((participantsCount) => {
|
||||||
|
this.jitsiParticipantsCount = participantsCount;
|
||||||
|
this.tryChangeShowVoiceIndicatorState(this.jitsiDominantSpeaker && this.jitsiParticipantsCount > 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.availabilityStatusStoreUnsubscriber = availabilityStatusStore.subscribe((status) => {
|
||||||
|
this.connection?.emitPlayerStatusChange(status);
|
||||||
|
this.CurrentPlayer.setStatus(status);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.emoteUnsubscriber = emoteStore.subscribe((emote) => {
|
||||||
|
if (emote) {
|
||||||
|
this.CurrentPlayer?.playEmote(emote.url);
|
||||||
|
this.connection?.emitEmoteEvent(emote.url);
|
||||||
|
emoteStore.set(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.emoteMenuUnsubscriber = emoteMenuStore.subscribe((emoteMenu) => {
|
||||||
|
if (emoteMenu) {
|
||||||
|
this.userInputManager.disableControls();
|
||||||
|
} else {
|
||||||
|
this.userInputManager.restoreControls();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.followUsersColorStoreUnsubscriber = followUsersColorStore.subscribe((color) => {
|
||||||
|
if (color !== undefined) {
|
||||||
|
this.CurrentPlayer.setFollowOutlineColor(color);
|
||||||
|
this.connection?.emitPlayerOutlineColor(color);
|
||||||
|
} else {
|
||||||
|
this.CurrentPlayer.removeFollowOutlineColor();
|
||||||
|
this.connection?.emitPlayerOutlineColor(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// From now, this game scene will be notified of reposition events
|
||||||
|
this.biggestAvailableAreaStoreUnsubscriber = biggestAvailableAreaStore.subscribe((box) =>
|
||||||
|
this.cameraManager.updateCameraOffset(box)
|
||||||
|
);
|
||||||
|
|
||||||
|
const talkIconVolumeTreshold = 10;
|
||||||
|
let oldPeersNumber = 0;
|
||||||
|
this.peerStoreUnsubscriber = peerStore.subscribe((peers) => {
|
||||||
|
const newPeerNumber = peers.size;
|
||||||
|
if (newPeerNumber > oldPeersNumber) {
|
||||||
|
this.playSound("audio-webrtc-in");
|
||||||
|
} else if (newPeerNumber < oldPeersNumber) {
|
||||||
|
this.playSound("audio-webrtc-out");
|
||||||
|
}
|
||||||
|
if (newPeerNumber > 0) {
|
||||||
|
if (!this.localVolumeStoreUnsubscriber) {
|
||||||
|
this.localVolumeStoreUnsubscriber = localVolumeStore.subscribe((volume) => {
|
||||||
|
if (volume === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.tryChangeShowVoiceIndicatorState(volume > talkIconVolumeTreshold);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.CurrentPlayer.showTalkIcon(false, true);
|
||||||
|
this.connection?.emitPlayerShowVoiceIndicator(false);
|
||||||
|
this.showVoiceIndicatorChangeMessageSent = false;
|
||||||
|
this.MapPlayersByKey.forEach((remotePlayer) => remotePlayer.showTalkIcon(false, true));
|
||||||
|
if (this.localVolumeStoreUnsubscriber) {
|
||||||
|
this.localVolumeStoreUnsubscriber();
|
||||||
|
this.localVolumeStoreUnsubscriber = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
oldPeersNumber = peers.size;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
//todo: into dedicated classes
|
//todo: into dedicated classes
|
||||||
private initCirclesCanvas(): void {
|
private initCirclesCanvas(): void {
|
||||||
// Let's generate the circle for the group delimiter
|
// Let's generate the circle for the group delimiter
|
||||||
@ -1609,11 +1613,11 @@ ${escapedMessage}
|
|||||||
this.pinchManager?.destroy();
|
this.pinchManager?.destroy();
|
||||||
this.emoteManager?.destroy();
|
this.emoteManager?.destroy();
|
||||||
this.cameraManager.destroy();
|
this.cameraManager.destroy();
|
||||||
this.peerStoreUnsubscribe();
|
this.peerStoreUnsubscriber();
|
||||||
this.emoteUnsubscribe();
|
this.emoteUnsubscriber();
|
||||||
this.emoteMenuUnsubscribe();
|
this.emoteMenuUnsubscriber();
|
||||||
this.followUsersColorStoreUnsubscribe();
|
this.followUsersColorStoreUnsubscriber();
|
||||||
this.biggestAvailableAreaStoreUnsubscribe();
|
this.biggestAvailableAreaStoreUnsubscriber();
|
||||||
this.userIsJitsiDominantSpeakerStoreUnsubscriber();
|
this.userIsJitsiDominantSpeakerStoreUnsubscriber();
|
||||||
this.jitsiParticipantsCountStoreUnsubscriber();
|
this.jitsiParticipantsCountStoreUnsubscriber();
|
||||||
this.availabilityStatusStoreUnsubscriber();
|
this.availabilityStatusStoreUnsubscriber();
|
||||||
|
Loading…
Reference in New Issue
Block a user