Compare commits

..

2 Commits

Author SHA1 Message Date
241182ed2e 1.0.40 2019-04-22 22:04:53 +02:00
3d82038ec3 fix(core): update 2019-04-22 22:04:52 +02:00
4 changed files with 20 additions and 6 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartuniverse", "name": "@pushrocks/smartuniverse",
"version": "1.0.39", "version": "1.0.40",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartuniverse", "name": "@pushrocks/smartuniverse",
"version": "1.0.39", "version": "1.0.40",
"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",

View File

@ -36,6 +36,12 @@ export class ClientUniverse {
* TODO: verify channel before adding it to the channel cache * TODO: verify channel before adding it to the channel cache
*/ */
public async addChannel (channelNameArg: string, passphraseArg: string) { public async addChannel (channelNameArg: string, passphraseArg: string) {
const existingChannel = this.getChannel(channelNameArg);
if (existingChannel) {
throw new Error('channel exists');
}
const clientUniverseChannel = await ClientUniverseChannel.createClientUniverseChannel( const clientUniverseChannel = await ClientUniverseChannel.createClientUniverseChannel(
this, this,
channelNameArg, channelNameArg,
@ -49,8 +55,11 @@ export class ClientUniverse {
* @param channelName * @param channelName
* @param passphraseArg * @param passphraseArg
*/ */
public async getChannel(channelName: string, passphraseArg?: string): Promise<ClientUniverseChannel> { public async getChannel(channelName: string): Promise<ClientUniverseChannel> {
await this.checkConnection(); await this.checkConnection();
const clientUniverseChannel = this.channelCache.find(channel => {
return channel.name === channelName;
})
return clientUniverseChannel; return clientUniverseChannel;
} }

View File

@ -21,11 +21,16 @@ export class ClientUniverseChannel implements interfaces.IUniverseChannel {
// INSTANCE // INSTANCE
// ======== // ========
public clientUniverse: ClientUniverse; // properties
public name: string;
public passphrase: string; public passphrase: string;
constructor(clientUniverseArg: ClientUniverse, passphraseArg: string) { // refs
public clientUniverse: ClientUniverse;
constructor(clientUniverseArg: ClientUniverse, nameArg: string, passphraseArg: string) {
this.clientUniverse = clientUniverseArg; this.clientUniverse = clientUniverseArg;
this.name = nameArg;
this.passphrase = passphraseArg; this.passphrase = passphraseArg;
} }