fix(core): update
This commit is contained in:
parent
f3e13292d8
commit
64c4b91678
@ -15,6 +15,6 @@ export interface ISocketRequest_ProcessMessage {
|
|||||||
method: 'processMessage';
|
method: 'processMessage';
|
||||||
request: interfaces.IUniverseMessage;
|
request: interfaces.IUniverseMessage;
|
||||||
response: {
|
response: {
|
||||||
messageStatus: 'ok'
|
messageStatus: 'ok' | 'channel not found'
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -113,17 +113,30 @@ export class ClientUniverse {
|
|||||||
/**
|
/**
|
||||||
* handles message reception
|
* handles message reception
|
||||||
*/
|
*/
|
||||||
const socketFunctionProcessMessage = new plugins.smartsocket.SocketFunction<interfaces.ISocketRequest_ProcessMessage>({
|
const socketFunctionProcessMessage = new plugins.smartsocket.SocketFunction<
|
||||||
|
interfaces.ISocketRequest_ProcessMessage
|
||||||
|
>({
|
||||||
funcName: 'processMessage',
|
funcName: 'processMessage',
|
||||||
allowedRoles: [],
|
allowedRoles: [],
|
||||||
funcDef: async (messageDescriptorArg) => {
|
funcDef: async messageDescriptorArg => {
|
||||||
plugins.smartlog.defaultLogger.log('info', 'Got message from server');
|
plugins.smartlog.defaultLogger.log('info', 'Got message from server');
|
||||||
this.observableIntake.push(
|
const clientUniverseMessage = ClientUniverseMessage.createMessageFromMessageDescriptor(
|
||||||
ClientUniverseMessage.createMessageFromMessageDescriptor(messageDescriptorArg)
|
messageDescriptorArg
|
||||||
);
|
);
|
||||||
|
this.observableIntake.push(clientUniverseMessage);
|
||||||
|
|
||||||
|
// lets find the corresponding channel
|
||||||
|
const targetChannel = this.getChannel(clientUniverseMessage.targetChannelName);
|
||||||
|
if (targetChannel) {
|
||||||
|
await targetChannel.emitMessageLocally(clientUniverseMessage);
|
||||||
return {
|
return {
|
||||||
messageStatus: 'ok'
|
messageStatus: 'ok'
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
messageStatus: 'channel not found'
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ import * as plugins from './smartuniverse.plugins';
|
|||||||
import * as interfaces from './interfaces';
|
import * as interfaces from './interfaces';
|
||||||
|
|
||||||
import { ClientUniverse } from './';
|
import { ClientUniverse } from './';
|
||||||
|
import { ClientUniverseMessage } from './smartuniverse.classes.clientuniversemessage';
|
||||||
|
|
||||||
export class ClientUniverseChannel implements interfaces.IUniverseChannel {
|
export class ClientUniverseChannel implements interfaces.IUniverseChannel {
|
||||||
// ======
|
// ======
|
||||||
@ -35,6 +36,7 @@ export class ClientUniverseChannel implements interfaces.IUniverseChannel {
|
|||||||
public name: string;
|
public name: string;
|
||||||
public passphrase: string;
|
public passphrase: string;
|
||||||
public status: 'subscribed' | 'unsubscribed' = 'unsubscribed';
|
public status: 'subscribed' | 'unsubscribed' = 'unsubscribed';
|
||||||
|
private subject = new plugins.smartrx.rxjs.Subject();
|
||||||
|
|
||||||
// refs
|
// refs
|
||||||
public clientUniverseRef: ClientUniverse;
|
public clientUniverseRef: ClientUniverse;
|
||||||
@ -49,7 +51,8 @@ export class ClientUniverseChannel implements interfaces.IUniverseChannel {
|
|||||||
* subscribes to a channel
|
* subscribes to a channel
|
||||||
* tells the universe about this instances interest into a channel
|
* tells the universe about this instances interest into a channel
|
||||||
*/
|
*/
|
||||||
public async subscribe() {
|
public async subscribe(observerArg?: plugins.smartrx.rxjs.Observer<any>) {
|
||||||
|
// lets make sure the channel is connected
|
||||||
if (this.status === 'unsubscribed') {
|
if (this.status === 'unsubscribed') {
|
||||||
const response = await this.clientUniverseRef.smartsocketClient.serverCall<interfaces.ISocketRequest_SubscribeChannel>(
|
const response = await this.clientUniverseRef.smartsocketClient.serverCall<interfaces.ISocketRequest_SubscribeChannel>(
|
||||||
'subscribeChannel',
|
'subscribeChannel',
|
||||||
@ -60,6 +63,15 @@ export class ClientUniverseChannel implements interfaces.IUniverseChannel {
|
|||||||
);
|
);
|
||||||
this.status = response.subscriptionStatus;
|
this.status = response.subscriptionStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (observerArg) {
|
||||||
|
return this.subject.subscribe(observerArg);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public async emitMessageLocally(messageArg: ClientUniverseMessage) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
import * as plugins from './smartuniverse.plugins';
|
import * as plugins from './smartuniverse.plugins';
|
||||||
|
|
||||||
export class ReactionRequest {}
|
export class ReactionRequest {
|
||||||
|
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user