fix(core): update
This commit is contained in:
parent
f3d41b8719
commit
ff7cdc908c
6
package-lock.json
generated
6
package-lock.json
generated
@ -1243,7 +1243,7 @@
|
|||||||
},
|
},
|
||||||
"esutils": {
|
"esutils": {
|
||||||
"version": "2.0.3",
|
"version": "2.0.3",
|
||||||
"resolved": "https://verdaccio.lossless.one/esutils/-/esutils-2.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
|
||||||
"integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
|
"integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
@ -1949,7 +1949,7 @@
|
|||||||
},
|
},
|
||||||
"minimist": {
|
"minimist": {
|
||||||
"version": "0.0.8",
|
"version": "0.0.8",
|
||||||
"resolved": "https://verdaccio.lossless.one/minimist/-/minimist-0.0.8.tgz",
|
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
|
||||||
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
|
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
@ -2364,7 +2364,7 @@
|
|||||||
},
|
},
|
||||||
"resolve": {
|
"resolve": {
|
||||||
"version": "1.12.0",
|
"version": "1.12.0",
|
||||||
"resolved": "https://verdaccio.lossless.one/resolve/-/resolve-1.12.0.tgz",
|
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz",
|
||||||
"integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==",
|
"integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
"rxjs": "*"
|
"rxjs": "*"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@apiglobal/typedrequest-interfaces": "^1.0.7",
|
||||||
"@pushrocks/lik": "^3.0.11",
|
"@pushrocks/lik": "^3.0.11",
|
||||||
"@pushrocks/smartdelay": "^2.0.3",
|
"@pushrocks/smartdelay": "^2.0.3",
|
||||||
"@pushrocks/smartexpress": "^3.0.40",
|
"@pushrocks/smartexpress": "^3.0.40",
|
||||||
|
@ -76,7 +76,7 @@ tap.test('should receive a message correctly', async (tools) => {
|
|||||||
const done = tools.defer();
|
const done = tools.defer();
|
||||||
const testChannel = testClientUniverse.getChannel(testChannelData.channelName);
|
const testChannel = testClientUniverse.getChannel(testChannelData.channelName);
|
||||||
const testChannel2 = testClientUniverse2.getChannel(testChannelData.channelName);
|
const testChannel2 = testClientUniverse2.getChannel(testChannelData.channelName);
|
||||||
const subscription = await testChannel2.subscribe(messageArg => {
|
const subscription = testChannel2.subscribe(messageArg => {
|
||||||
console.log('Yay##########');
|
console.log('Yay##########');
|
||||||
done.resolve();
|
done.resolve();
|
||||||
});
|
});
|
||||||
|
@ -9,4 +9,8 @@ export * from './smartuniverse.classes.universecache';
|
|||||||
export * from './smartuniverse.classes.universechannel';
|
export * from './smartuniverse.classes.universechannel';
|
||||||
export * from './smartuniverse.classes.universemessage';
|
export * from './smartuniverse.classes.universemessage';
|
||||||
|
|
||||||
|
// Reaction Response
|
||||||
|
export * from './smartuniverse.classes.reactionrequest';
|
||||||
|
export * from './smartuniverse.classes.reactionresponse';
|
||||||
|
|
||||||
export * from './interfaces';
|
export * from './interfaces';
|
||||||
|
@ -147,7 +147,7 @@ export class ClientUniverse {
|
|||||||
await this.smartsocketClient.connect();
|
await this.smartsocketClient.connect();
|
||||||
plugins.smartlog.defaultLogger.log('info', 'universe client connected successfully');
|
plugins.smartlog.defaultLogger.log('info', 'universe client connected successfully');
|
||||||
await this.clientUniverseCache.channelMap.forEach(async clientUniverseChannelArg => {
|
await this.clientUniverseCache.channelMap.forEach(async clientUniverseChannelArg => {
|
||||||
await clientUniverseChannelArg.subscribe();
|
await clientUniverseChannelArg.populateSubscriptionToServer();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,17 @@ 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(observingFunctionArg?: (messageArg: ClientUniverseMessage) => void) {
|
public subscribe(observingFunctionArg: (messageArg: ClientUniverseMessage) => void) {
|
||||||
|
|
||||||
|
return this.subject.subscribe(
|
||||||
|
messageArg => {
|
||||||
|
observingFunctionArg(messageArg);
|
||||||
|
},
|
||||||
|
error => console.log(error)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async populateSubscriptionToServer() {
|
||||||
// lets make sure the channel is connected
|
// lets make sure the channel is connected
|
||||||
if (this.status === 'unsubscribed') {
|
if (this.status === 'unsubscribed') {
|
||||||
const response = await this.clientUniverseRef.smartsocketClient.serverCall<
|
const response = await this.clientUniverseRef.smartsocketClient.serverCall<
|
||||||
@ -64,23 +74,12 @@ export class ClientUniverseChannel implements interfaces.IUniverseChannel {
|
|||||||
});
|
});
|
||||||
this.status = response.subscriptionStatus;
|
this.status = response.subscriptionStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (observingFunctionArg) {
|
|
||||||
return this.subject.subscribe(messageArg => {
|
|
||||||
observingFunctionArg(messageArg);
|
|
||||||
},error => console.log);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async emitMessageLocally(messageArg: ClientUniverseMessage) {
|
public async emitMessageLocally(messageArg: ClientUniverseMessage) {
|
||||||
this.subject.next(messageArg);
|
this.subject.next(messageArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public askForReaction(reactionRequest: ReactionRequest): ReactionResponse {
|
|
||||||
const reactionResponse = new ReactionResponse();
|
|
||||||
return reactionResponse;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sends a message towards the server
|
* sends a message towards the server
|
||||||
* @param messageArg
|
* @param messageArg
|
||||||
|
@ -1,3 +1,24 @@
|
|||||||
import * as plugins from './smartuniverse.plugins';
|
import * as plugins from './smartuniverse.plugins';
|
||||||
|
|
||||||
export class ReactionRequest {}
|
export interface IReactionRequestConstructorOptions<T extends plugins.typedrequestInterfaces.ITypedRequest> {
|
||||||
|
method: T['method'];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ICombinatorPayload<T extends plugins.typedrequestInterfaces.ITypedRequest> {
|
||||||
|
/**
|
||||||
|
* needed for tying responses to requests
|
||||||
|
*/
|
||||||
|
id: string;
|
||||||
|
typedRequestPayload: T;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ReactionRequest<T extends plugins.typedrequestInterfaces.ITypedRequest> {
|
||||||
|
public method: T['method'];
|
||||||
|
|
||||||
|
constructor(optionsArg: IReactionRequestConstructorOptions<T>) {
|
||||||
|
this.method = optionsArg.method;
|
||||||
|
}
|
||||||
|
|
||||||
|
public fireRequest(channelArg) {}
|
||||||
|
}
|
||||||
|
@ -1,5 +1,31 @@
|
|||||||
import * as plugins from './smartuniverse.plugins';
|
import * as plugins from './smartuniverse.plugins';
|
||||||
|
|
||||||
export class ReactionResponse {
|
import { ICombinatorPayload } from './smartuniverse.classes.reactionrequest';
|
||||||
|
import { UniverseChannel } from './smartuniverse.classes.universechannel';
|
||||||
|
import { ClientUniverseChannel } from './smartuniverse.classes.clientuniversechannel';
|
||||||
|
import { UniverseMessage } from './smartuniverse.classes.universemessage';
|
||||||
|
import { ClientUniverseMessage } from './smartuniverse.classes.clientuniversemessage';
|
||||||
|
|
||||||
|
export interface IReactionResponseConstructorOptions<T extends plugins.typedrequestInterfaces.ITypedRequest> {
|
||||||
|
method: T['method'];
|
||||||
|
channels: Array<UniverseChannel | ClientUniverseChannel>;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export class ReactionResponse<T extends plugins.typedrequestInterfaces.ITypedRequest> {
|
||||||
|
public method: T['method'];
|
||||||
|
public channels = new plugins.lik.Objectmap<UniverseChannel | ClientUniverseChannel>();
|
||||||
|
|
||||||
|
constructor(optionsArg: IReactionResponseConstructorOptions<T>) {
|
||||||
|
this.channels.addArray(optionsArg.channels);
|
||||||
|
for (const channel of this.channels.getArray()) {
|
||||||
|
channel.subscribe(messageArg => {
|
||||||
|
this.processMessageForReaction(messageArg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private processMessageForReaction(messageArg: UniverseMessage | ClientUniverseMessage) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -143,8 +143,13 @@ export class UniverseChannel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// functions to interact with a channel locally
|
// functions to interact with a channel locally
|
||||||
public async subscribe(observer: plugins.smartrx.rxjs.Observer<any>) {
|
public subscribe(observingFunctionArg: (messageArg: UniverseMessage) => void) {
|
||||||
return this.subject.subscribe(observer);
|
return this.subject.subscribe(
|
||||||
|
messageArg => {
|
||||||
|
observingFunctionArg(messageArg);
|
||||||
|
},
|
||||||
|
error => console.log(error)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,6 +3,13 @@ import * as path from 'path';
|
|||||||
|
|
||||||
export { path };
|
export { path };
|
||||||
|
|
||||||
|
// apiglobal scope
|
||||||
|
import * as typedrequestInterfaces from '@apiglobal/typedrequest-interfaces';
|
||||||
|
|
||||||
|
export {
|
||||||
|
typedrequestInterfaces
|
||||||
|
};
|
||||||
|
|
||||||
// pushrocks scope
|
// pushrocks scope
|
||||||
import * as lik from '@pushrocks/lik';
|
import * as lik from '@pushrocks/lik';
|
||||||
import * as smarthash from '@pushrocks/smarthash';
|
import * as smarthash from '@pushrocks/smarthash';
|
||||||
|
Loading…
Reference in New Issue
Block a user