fix(core): update

This commit is contained in:
Philipp Kunz 2019-08-13 18:41:27 +02:00
parent e100dea160
commit 857b7cd010
3 changed files with 9 additions and 8 deletions

View File

@ -49,12 +49,12 @@ tap.test('should start the ClientUniverse', async () => {
}) })
tap.test('should get a observable correctly', 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); expect(testClientChannel).to.be.instanceof(smartuniverse.ClientUniverseChannel);
}); });
tap.test('should send a message correctly', async () => { tap.test('should send a message correctly', async () => {
await (await testClientUniverse.getChannel(testChannelData.channelName)).sendMessage({ await (testClientUniverse.getChannel(testChannelData.channelName)).sendMessage({
messageText: 'hello' messageText: 'hello'
}); });
}); });

View File

@ -32,15 +32,16 @@ export class ClientUniverse {
* adds a channel to the channelcache * adds a channel to the channelcache
* 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 addChannel(channelNameArg: string, passphraseArg: string) {
const existingChannel = await this.getChannel(channelNameArg); const existingChannel = this.getChannel(channelNameArg);
if (existingChannel) { if (existingChannel) {
throw new Error('channel exists'); throw new Error('channel exists');
} }
// lets create the channel // 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 channelName
* @param passphraseArg * @param passphraseArg
*/ */
public async getChannel(channelName: string): Promise<ClientUniverseChannel> { public getChannel(channelName: string): ClientUniverseChannel {
const clientUniverseChannel = this.clientUniverseCache.channelMap.find(channel => { const clientUniverseChannel = this.clientUniverseCache.channelMap.find(channel => {
return channel.name === channelName; return channel.name === channelName;
}); });

View File

@ -13,11 +13,11 @@ export class ClientUniverseChannel implements interfaces.IUniverseChannel {
* @param channelNameArg * @param channelNameArg
* @param passphraseArg * @param passphraseArg
*/ */
public static async createClientUniverseChannel( public static createClientUniverseChannel(
clientUniverseArg: ClientUniverse, clientUniverseArg: ClientUniverse,
channelNameArg: string, channelNameArg: string,
passphraseArg: string passphraseArg: string
): Promise<ClientUniverseChannel> { ): ClientUniverseChannel {
const clientChannel = new ClientUniverseChannel( const clientChannel = new ClientUniverseChannel(
clientUniverseArg, clientUniverseArg,
channelNameArg, channelNameArg,