fix(core): update

This commit is contained in:
2019-06-06 23:23:37 +02:00
parent df45287026
commit bee5231d47
12 changed files with 392 additions and 335 deletions

View File

@ -8,9 +8,7 @@ import * as url from 'url';
import * as interfaces from './interfaces';
import { ClientUniverseChannel, UniverseMessage } from './';
import {
ClientUniverseCache
} from './smartuniverse.classes.clientuniversecache';
import { ClientUniverseCache } from './smartuniverse.classes.clientuniversecache';
export interface IClientOptions {
serverAddress: string;
@ -70,10 +68,9 @@ export class ClientUniverse {
});
}
/**
* sends a message towards the server
* @param messageArg
* @param messageArg
*/
public async sendMessage(messageArg: interfaces.IMessageCreator) {
await this.checkConnection();
@ -116,19 +113,13 @@ export class ClientUniverse {
const unsubscribe = new plugins.smartsocket.SocketFunction({
funcName: 'unsubscribe',
allowedRoles: [],
funcDef: async (data: interfaces.IServerUnsubscribeActionPayload) => {
},
funcDef: async (data: interfaces.IServerUnsubscribeActionPayload) => {}
});
/**
* should handle a message reception
*/
const receiveMessage = async () => {
};
const receiveMessage = async () => {};
await this.smartsocketClient.connect();
}

View File

@ -5,6 +5,4 @@ import * as plugins from './smartuniverse.plugins';
* keeps track of which messages have already been received
* good for deduplication in mesh environments
*/
export class ClientUniverseCache {
}
export class ClientUniverseCache {}

View File

@ -30,5 +30,5 @@ export class ClientUniverseMessage implements interfaces.IUniverseMessage {
}
}
getAsJsonForPayload() {};
getAsJsonForPayload() {}
}

View File

@ -93,11 +93,15 @@ export class Universe {
this.smartsocket.addSocketRoles([ClientRole]);
const SubscriptionSocketFunction = new plugins.smartsocket.SocketFunction({
allowedRoles: [ClientRole],
allowedRoles: [ClientRole], // there is only one client role, Authentication happens on another level
funcName: 'channelSubscription',
funcDef: (data) => {
funcDef: async (dataArg, socketConnectionArg) => {
// run in "this context" of this class
(() => {
// TODO:
// TODO: properly add the connection
const universeConnection = new UniverseConnection({
})
this.universeConnectionManager.addConnection();
})();
}
@ -109,7 +113,6 @@ export class Universe {
await this.smartexpressServer.start();
await this.smartsocket.start();
console.log('started universe');
}
/**

View File

@ -52,7 +52,10 @@ export class UniverseCache {
/**
* Read a message from the UniverseCache
*/
public readMessagesYoungerThan(unixTimeArg?: number, channelName?: string): Observable<UniverseMessage> {
public readMessagesYoungerThan(
unixTimeArg?: number,
channelName?: string
): Observable<UniverseMessage> {
const messageObservable = from(this.messageMap.getArray()).pipe(
filter(messageArg => {
return messageArg.smartTimestamp.isYoungerThanMilliSeconds(this.destructionTime);

View File

@ -88,7 +88,5 @@ export class UniverseChannel {
);
}
public pushToClients(messageArg: UniverseMessage) {
}
public pushToClients(messageArg: UniverseMessage) {}
}

View File

@ -1,8 +1,6 @@
import * as plugins from './smartuniverse.plugins';
import { UniverseChannel } from './smartuniverse.classes.universechannel';
/**
* represents a connection to the universe
*/
@ -10,11 +8,19 @@ export class UniverseConnection {
/**
* the socketClient to ping
*/
socketclient: plugins.smartsocket.SmartsocketClient;
subscribedChannels: UniverseChannel[] = [];
authenticatedChannels: UniverseChannel[] = [];
constructor() {
public socketConnection: plugins.smartsocket.SocketConnection;
public authenticationRequests = []
public subscribedChannels: UniverseChannel[] = [];
public authenticatedChannels: UniverseChannel[] = [];
public failedToJoinChannels: UniverseChannel[] = [];
public terminateConnection () {
this.socketConnection
}
}
constructor(optionsArg: {
socketConnection: plugins.smartsocket.SocketConnection;
}) {
this.socketConnection,
}
}

View File

@ -8,4 +8,4 @@ export class UniverseConnectionManager {
public connectionMap = new plugins.lik.Objectmap<UniverseConnection>();
public addConnection() {}
}
}