From 857b7cd01011e4768e6663fd33b6d61a8d6a1818 Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Tue, 13 Aug 2019 18:41:27 +0200 Subject: [PATCH] fix(core): update --- test/test.ts | 4 ++-- ts/smartuniverse.classes.clientuniverse.ts | 9 +++++---- ts/smartuniverse.classes.clientuniversechannel.ts | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/test/test.ts b/test/test.ts index 22fbd0a..8e65940 100644 --- a/test/test.ts +++ b/test/test.ts @@ -49,12 +49,12 @@ tap.test('should start the ClientUniverse', async () => { }) tap.test('should get a observable correctly', async () => { - testClientChannel = await testClientUniverse.getChannel(testChannelData.channelName); + testClientChannel = testClientUniverse.getChannel(testChannelData.channelName); expect(testClientChannel).to.be.instanceof(smartuniverse.ClientUniverseChannel); }); tap.test('should send a message correctly', async () => { - await (await testClientUniverse.getChannel(testChannelData.channelName)).sendMessage({ + await (testClientUniverse.getChannel(testChannelData.channelName)).sendMessage({ messageText: 'hello' }); }); diff --git a/ts/smartuniverse.classes.clientuniverse.ts b/ts/smartuniverse.classes.clientuniverse.ts index f019566..6e57366 100644 --- a/ts/smartuniverse.classes.clientuniverse.ts +++ b/ts/smartuniverse.classes.clientuniverse.ts @@ -32,15 +32,16 @@ export class ClientUniverse { * adds a channel to the channelcache * TODO: verify channel before adding it to the channel cache */ - public async addChannel(channelNameArg: string, passphraseArg: string) { - const existingChannel = await this.getChannel(channelNameArg); + public addChannel(channelNameArg: string, passphraseArg: string) { + const existingChannel = this.getChannel(channelNameArg); if (existingChannel) { throw new Error('channel exists'); } // lets create the channel - await ClientUniverseChannel.createClientUniverseChannel(this, channelNameArg, passphraseArg); + const clientUniverseChannel = ClientUniverseChannel.createClientUniverseChannel(this, channelNameArg, passphraseArg); + return clientUniverseChannel; } /** @@ -48,7 +49,7 @@ export class ClientUniverse { * @param channelName * @param passphraseArg */ - public async getChannel(channelName: string): Promise { + public getChannel(channelName: string): ClientUniverseChannel { const clientUniverseChannel = this.clientUniverseCache.channelMap.find(channel => { return channel.name === channelName; }); diff --git a/ts/smartuniverse.classes.clientuniversechannel.ts b/ts/smartuniverse.classes.clientuniversechannel.ts index f5eaf33..74b0b9c 100644 --- a/ts/smartuniverse.classes.clientuniversechannel.ts +++ b/ts/smartuniverse.classes.clientuniversechannel.ts @@ -13,11 +13,11 @@ export class ClientUniverseChannel implements interfaces.IUniverseChannel { * @param channelNameArg * @param passphraseArg */ - public static async createClientUniverseChannel( + public static createClientUniverseChannel( clientUniverseArg: ClientUniverse, channelNameArg: string, passphraseArg: string - ): Promise { + ): ClientUniverseChannel { const clientChannel = new ClientUniverseChannel( clientUniverseArg, channelNameArg,