fix: should now sync with other devices
Queue Release Build / prepare (push) Successful in 25s
Deploy Web Apps / deploy (push) Successful in 7m8s
Queue Release Build / build-windows (push) Successful in 28m10s
Queue Release Build / build-linux (push) Successful in 44m38s
Queue Release Build / build-android (push) Successful in 18m36s
Queue Release Build / finalize (push) Successful in 1m40s
Queue Release Build / prepare (push) Successful in 25s
Deploy Web Apps / deploy (push) Successful in 7m8s
Queue Release Build / build-windows (push) Successful in 28m10s
Queue Release Build / build-linux (push) Successful in 44m38s
Queue Release Build / build-android (push) Successful in 18m36s
Queue Release Build / finalize (push) Successful in 1m40s
This commit is contained in:
@@ -17,9 +17,15 @@ import {
|
||||
inject,
|
||||
OnDestroy
|
||||
} from '@angular/core';
|
||||
import { Observable, Subject } from 'rxjs';
|
||||
import { Observable, Subject, merge } from 'rxjs';
|
||||
import { ChatEvent } from '../../shared-kernel';
|
||||
import type { SignalingMessage } from '../../shared-kernel';
|
||||
import {
|
||||
isRelayableAccountSyncEvent,
|
||||
shouldApplyAccountSyncPayload,
|
||||
unwrapAccountSyncPayload,
|
||||
type AccountSyncSignalingMessage
|
||||
} from './account-sync/account-sync.rules';
|
||||
import { TimeSyncService } from '../../core/services/time-sync.service';
|
||||
import { DebuggingService } from '../../core/services/debugging';
|
||||
import { ScreenShareSourcePickerService } from '../../domains/screen-share';
|
||||
@@ -83,12 +89,14 @@ export class WebRTCService implements OnDestroy {
|
||||
private readonly signalingMessage$ = new Subject<IncomingSignalingMessage>();
|
||||
readonly onSignalingMessage = this.signalingMessage$.asObservable();
|
||||
|
||||
private readonly accountSyncRelay$ = new Subject<ChatEvent>();
|
||||
|
||||
private readonly signalingReconnectedSubject$ = new Subject<string>();
|
||||
readonly signalingReconnected$ = this.signalingReconnectedSubject$.asObservable();
|
||||
|
||||
// Delegates to managers
|
||||
get onMessageReceived(): Observable<ChatEvent> {
|
||||
return this.peerMediaFacade.onMessageReceived;
|
||||
return merge(this.peerMediaFacade.onMessageReceived, this.accountSyncRelay$);
|
||||
}
|
||||
get onPeerConnected(): Observable<string> {
|
||||
return this.peerMediaFacade.onPeerConnected;
|
||||
@@ -304,6 +312,19 @@ export class WebRTCService implements OnDestroy {
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.type === 'account_sync') {
|
||||
const accountMessage = message as AccountSyncSignalingMessage;
|
||||
|
||||
if (shouldApplyAccountSyncPayload(
|
||||
accountMessage.clientInstanceId,
|
||||
this.clientInstance.getClientInstanceId()
|
||||
)) {
|
||||
this.accountSyncRelay$.next(unwrapAccountSyncPayload(accountMessage));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.signalingMessage$.next(message);
|
||||
this.signalingMessageHandler.handleMessage(message, signalUrl);
|
||||
}
|
||||
@@ -451,6 +472,24 @@ export class WebRTCService implements OnDestroy {
|
||||
this.relayBroadcastEvent(event);
|
||||
}
|
||||
|
||||
/** Relay account-owned state to the user's other connected devices. */
|
||||
relayAccountSync(event: ChatEvent): void {
|
||||
if (!isRelayableAccountSyncEvent(event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const clientInstanceId = this.clientInstance.getClientInstanceId();
|
||||
|
||||
this.signalingTransportHandler.sendRawMessage({
|
||||
type: 'account_sync',
|
||||
clientInstanceId,
|
||||
payload: {
|
||||
...event,
|
||||
clientInstanceId
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a {@link ChatEvent} to a specific peer.
|
||||
*
|
||||
@@ -742,7 +781,11 @@ export class WebRTCService implements OnDestroy {
|
||||
},
|
||||
clientInstanceId
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.relayAccountSync(event);
|
||||
}
|
||||
|
||||
requestVoiceClientTakeover(): void {
|
||||
|
||||
Reference in New Issue
Block a user