Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
0d18b11721 | |||
eaaefddbe3 | |||
8c6946ddb6 | |||
3a7ebcdd80 |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartuniverse",
|
"name": "@pushrocks/smartuniverse",
|
||||||
"version": "1.0.59",
|
"version": "1.0.61",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartuniverse",
|
"name": "@pushrocks/smartuniverse",
|
||||||
"version": "1.0.59",
|
"version": "1.0.61",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "messaging service for your micro services",
|
"description": "messaging service for your micro services",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
@ -30,6 +30,7 @@
|
|||||||
"@pushrocks/smartexpress": "^3.0.38",
|
"@pushrocks/smartexpress": "^3.0.38",
|
||||||
"@pushrocks/smartfile": "^7.0.4",
|
"@pushrocks/smartfile": "^7.0.4",
|
||||||
"@pushrocks/smarthash": "^2.0.6",
|
"@pushrocks/smarthash": "^2.0.6",
|
||||||
|
"@pushrocks/smartlog": "^2.0.19",
|
||||||
"@pushrocks/smartpromise": "^3.0.2",
|
"@pushrocks/smartpromise": "^3.0.2",
|
||||||
"@pushrocks/smartrequest": "^1.1.16",
|
"@pushrocks/smartrequest": "^1.1.16",
|
||||||
"@pushrocks/smartrx": "^2.0.3",
|
"@pushrocks/smartrx": "^2.0.3",
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Client classes
|
// Client classes
|
||||||
export * from './smartuniverse.classes.clientuniverse';
|
export * from './smartuniverse.classes.clientuniverse';
|
||||||
export * from './smartuniverse.classes.clientuniversechannel';
|
export * from './smartuniverse.classes.clientuniversechannel';
|
||||||
|
export * from './smartuniverse.classes.clientuniversemessage';
|
||||||
|
|
||||||
// Server classes
|
// Server classes
|
||||||
export * from './smartuniverse.classes.universe';
|
export * from './smartuniverse.classes.universe';
|
||||||
|
@ -7,7 +7,7 @@ import * as url from 'url';
|
|||||||
|
|
||||||
import * as interfaces from './interfaces';
|
import * as interfaces from './interfaces';
|
||||||
|
|
||||||
import { ClientUniverseChannel, UniverseMessage } from './';
|
import { ClientUniverseChannel, ClientUniverseMessage } from './';
|
||||||
import { ClientUniverseCache } from './smartuniverse.classes.clientuniversecache';
|
import { ClientUniverseCache } from './smartuniverse.classes.clientuniversecache';
|
||||||
|
|
||||||
export interface IClientOptions {
|
export interface IClientOptions {
|
||||||
@ -21,7 +21,7 @@ export interface IClientOptions {
|
|||||||
export class ClientUniverse {
|
export class ClientUniverse {
|
||||||
public options;
|
public options;
|
||||||
public smartsocketClient: plugins.smartsocket.SmartsocketClient;
|
public smartsocketClient: plugins.smartsocket.SmartsocketClient;
|
||||||
public observableIntake: plugins.smartrx.ObservableIntake<UniverseMessage>;
|
public observableIntake: plugins.smartrx.ObservableIntake<ClientUniverseMessage>;
|
||||||
public clientUniverseCache = new ClientUniverseCache();
|
public clientUniverseCache = new ClientUniverseCache();
|
||||||
|
|
||||||
constructor(optionsArg: IClientOptions) {
|
constructor(optionsArg: IClientOptions) {
|
||||||
@ -87,7 +87,6 @@ export class ClientUniverse {
|
|||||||
role: 'UniverseClient',
|
role: 'UniverseClient',
|
||||||
url: parsedURL.protocol + '//' + parsedURL.hostname
|
url: parsedURL.protocol + '//' + parsedURL.hostname
|
||||||
};
|
};
|
||||||
console.log(socketConfig);
|
|
||||||
this.smartsocketClient = new SmartsocketClient(socketConfig);
|
this.smartsocketClient = new SmartsocketClient(socketConfig);
|
||||||
this.observableIntake = new plugins.smartrx.ObservableIntake();
|
this.observableIntake = new plugins.smartrx.ObservableIntake();
|
||||||
|
|
||||||
@ -110,8 +109,9 @@ export class ClientUniverse {
|
|||||||
const socketFunctionProcessMessage = new plugins.smartsocket.SocketFunction({
|
const socketFunctionProcessMessage = new plugins.smartsocket.SocketFunction({
|
||||||
funcName: 'processMessage',
|
funcName: 'processMessage',
|
||||||
allowedRoles: [],
|
allowedRoles: [],
|
||||||
funcDef: async (data: interfaces.IServerUnsubscribeActionPayload) => {
|
funcDef: async (messageDescriptorArg: interfaces.IUniverseMessage) => {
|
||||||
console.log('Got message from server');
|
plugins.smartlog.defaultLogger.log('info', 'Got message from server');
|
||||||
|
this.observableIntake.push(ClientUniverseMessage.createMessageFromMessageDescriptor(messageDescriptorArg));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ export class ClientUniverse {
|
|||||||
this.smartsocketClient.addSocketFunction(socketFunctionProcessMessage);
|
this.smartsocketClient.addSocketFunction(socketFunctionProcessMessage);
|
||||||
|
|
||||||
await this.smartsocketClient.connect();
|
await this.smartsocketClient.connect();
|
||||||
console.log('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.subscribe();
|
||||||
});
|
});
|
||||||
|
@ -6,7 +6,10 @@ export class ClientUniverseMessage implements interfaces.IUniverseMessage {
|
|||||||
// ======
|
// ======
|
||||||
// STATIC
|
// STATIC
|
||||||
// ======
|
// ======
|
||||||
public static createMessageFromPayload(messageDescriptor: interfaces.IUniverseMessage) {}
|
public static createMessageFromMessageDescriptor(messageDescriptor: interfaces.IUniverseMessage) {
|
||||||
|
const clientuniverseMessage = new ClientUniverseMessage(messageDescriptor);
|
||||||
|
return clientuniverseMessage;
|
||||||
|
}
|
||||||
|
|
||||||
// ========
|
// ========
|
||||||
// INSTANCE
|
// INSTANCE
|
||||||
@ -23,11 +26,12 @@ export class ClientUniverseMessage implements interfaces.IUniverseMessage {
|
|||||||
public payloadStringType;
|
public payloadStringType;
|
||||||
public targetChannelName: string;
|
public targetChannelName: string;
|
||||||
|
|
||||||
constructor(messageArg: interfaces.IUniverseMessage, payloadArg) {
|
constructor(messageArg: interfaces.IUniverseMessage) {
|
||||||
for (const key of Object.keys(messageArg)) {
|
for (const key of Object.keys(messageArg)) {
|
||||||
this[key] = messageArg[key];
|
this[key] = messageArg[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
getAsJsonForPayload() {}
|
getAsJsonForPayload() {}
|
||||||
}
|
}
|
||||||
|
@ -121,8 +121,9 @@ export class Universe {
|
|||||||
socketConnectionArg
|
socketConnectionArg
|
||||||
);
|
);
|
||||||
if (universeConnection) {
|
if (universeConnection) {
|
||||||
console.log('found UniverseConnection for socket');
|
plugins.smartlog.defaultLogger.log('ok', 'found UniverseConnection for socket for incoming message');
|
||||||
} else {
|
} else {
|
||||||
|
plugins.smartlog.defaultLogger.log('warn', 'found no Authorized channel for incoming message');
|
||||||
return {
|
return {
|
||||||
error: 'You need to authenticate for a channel'
|
error: 'You need to authenticate for a channel'
|
||||||
};
|
};
|
||||||
@ -149,7 +150,7 @@ export class Universe {
|
|||||||
// start everything
|
// start everything
|
||||||
await this.smartexpressServer.start();
|
await this.smartexpressServer.start();
|
||||||
await this.smartsocket.start();
|
await this.smartsocket.start();
|
||||||
console.log('started universe');
|
plugins.smartlog.defaultLogger.log('success', 'started universe');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,12 +61,12 @@ export class UniverseChannel {
|
|||||||
if (foundChannel) {
|
if (foundChannel) {
|
||||||
universeMessageArg.authenticated = true;
|
universeMessageArg.authenticated = true;
|
||||||
universeMessageArg.universeChannelList.add(foundChannel);
|
universeMessageArg.universeChannelList.add(foundChannel);
|
||||||
console.log('message authorized');
|
plugins.smartlog.defaultLogger.log('ok', 'message authorized');
|
||||||
return foundChannel;
|
return foundChannel;
|
||||||
} else {
|
} else {
|
||||||
universeMessageArg.authenticated = false;
|
universeMessageArg.authenticated = false;
|
||||||
universeMessageArg.universeChannelList.add(universeCacheArg.blackListChannel);
|
universeMessageArg.universeChannelList.add(universeCacheArg.blackListChannel);
|
||||||
console.log('message not valid');
|
plugins.smartlog.defaultLogger.log('warn', 'message not valid');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,6 @@ export class UniverseConnection {
|
|||||||
universeConnectionArg: UniverseConnection
|
universeConnectionArg: UniverseConnection
|
||||||
): Promise<UniverseConnection> {
|
): Promise<UniverseConnection> {
|
||||||
for (const authenticationRequest of universeConnectionArg.authenticationRequests) {
|
for (const authenticationRequest of universeConnectionArg.authenticationRequests) {
|
||||||
// TODO: authenticate channel subscriptions
|
|
||||||
const universeChannelToAuthenticateAgainst = UniverseChannel.getUniverseChannelByName(universeRef, authenticationRequest.name);
|
const universeChannelToAuthenticateAgainst = UniverseChannel.getUniverseChannelByName(universeRef, authenticationRequest.name);
|
||||||
if (universeChannelToAuthenticateAgainst.passphrase === authenticationRequest.passphrase) {
|
if (universeChannelToAuthenticateAgainst.passphrase === authenticationRequest.passphrase) {
|
||||||
universeConnectionArg.authenticatedChannels.push(universeChannelToAuthenticateAgainst);
|
universeConnectionArg.authenticatedChannels.push(universeChannelToAuthenticateAgainst);
|
||||||
@ -74,7 +73,6 @@ export class UniverseConnection {
|
|||||||
connectionArg1: UniverseConnection,
|
connectionArg1: UniverseConnection,
|
||||||
connectionArg2: UniverseConnection
|
connectionArg2: UniverseConnection
|
||||||
) {
|
) {
|
||||||
// TODO: merge connections
|
|
||||||
return connectionArg1;
|
return connectionArg1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ export class UniverseMessage implements interfaces.IUniverseMessage {
|
|||||||
* handles bad messages for further analysis
|
* handles bad messages for further analysis
|
||||||
*/
|
*/
|
||||||
public handleAsBadMessage() {
|
public handleAsBadMessage() {
|
||||||
console.log('received a bad message');
|
plugins.smartlog.defaultLogger.log('warn', 'received a bad message');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9,6 +9,7 @@ import * as smarthash from '@pushrocks/smarthash';
|
|||||||
import * as smartdelay from '@pushrocks/smartdelay';
|
import * as smartdelay from '@pushrocks/smartdelay';
|
||||||
import * as smartexpress from '@pushrocks/smartexpress';
|
import * as smartexpress from '@pushrocks/smartexpress';
|
||||||
import * as smartfile from '@pushrocks/smartfile';
|
import * as smartfile from '@pushrocks/smartfile';
|
||||||
|
import * as smartlog from '@pushrocks/smartlog';
|
||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
import * as smartrequest from '@pushrocks/smartrequest';
|
import * as smartrequest from '@pushrocks/smartrequest';
|
||||||
import * as smartrx from '@pushrocks/smartrx';
|
import * as smartrx from '@pushrocks/smartrx';
|
||||||
@ -22,6 +23,7 @@ export {
|
|||||||
smartdelay,
|
smartdelay,
|
||||||
smartexpress,
|
smartexpress,
|
||||||
smartfile,
|
smartfile,
|
||||||
|
smartlog,
|
||||||
smartpromise,
|
smartpromise,
|
||||||
smartrx,
|
smartrx,
|
||||||
smartrequest,
|
smartrequest,
|
||||||
|
Reference in New Issue
Block a user