fix: signal disconnect loop on server start
this fixes the disconnect loop when the server has just started by waiting for the connection to open before subsribing to events. also includes other improvements: - rename types to interfaces - allow to input single receiver for signal - use discovery api to check for upgrade path instead hard coded one Signed-off-by: Heikki Hellgren <heikki.hellgren@op.fi>
This commit is contained in:
@@ -16,15 +16,15 @@ export class DefaultSignalService implements SignalService {
|
||||
|
||||
// @public (undocumented)
|
||||
export type SignalPayload = {
|
||||
recipients: string[] | null;
|
||||
receivers: string[] | string | null;
|
||||
channel: string;
|
||||
message: JsonObject;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export type SignalService = {
|
||||
export interface SignalService {
|
||||
publish(signal: SignalPayload): Promise<void>;
|
||||
};
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export const signalService: ServiceRef<SignalService, 'plugin'>;
|
||||
|
||||
@@ -37,11 +37,11 @@ export class DefaultSignalService implements SignalService {
|
||||
* @param message - message to publish
|
||||
*/
|
||||
async publish(signal: SignalPayload) {
|
||||
const { recipients, channel, message } = signal;
|
||||
const { receivers, channel, message } = signal;
|
||||
await this.eventBroker?.publish({
|
||||
topic: 'signals',
|
||||
eventPayload: {
|
||||
recipients,
|
||||
receivers,
|
||||
message,
|
||||
channel,
|
||||
},
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
import { SignalPayload } from './types';
|
||||
|
||||
/** @public */
|
||||
export type SignalService = {
|
||||
export interface SignalService {
|
||||
/**
|
||||
* Publishes a message to user refs to specific topic
|
||||
*/
|
||||
publish(signal: SignalPayload): Promise<void>;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ export type SignalServiceOptions = {
|
||||
|
||||
/** @public */
|
||||
export type SignalPayload = {
|
||||
recipients: string[] | null;
|
||||
receivers: string[] | string | null;
|
||||
channel: string;
|
||||
message: JsonObject;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user