Files
smartuniverse/ts/smartuniverse.classes.universechannel.ts

47 lines
1.1 KiB
TypeScript
Raw Normal View History

2018-04-13 15:45:48 +02:00
import * as plugins from './smartuniverse.plugins';
2018-04-29 14:17:26 +02:00
import { Objectmap } from 'lik';
2018-04-13 15:45:48 +02:00
/**
2018-04-29 14:17:26 +02:00
* enables messages to stay within a certain scope.
2018-04-13 15:45:48 +02:00
*/
export class UniverseChannel {
2018-04-29 14:17:26 +02:00
/**
* stores the channels that are available within the universe
*/
public static channelStore = new Objectmap();
2018-05-23 23:50:45 +02:00
2018-05-07 18:50:07 +02:00
/**
2018-05-20 00:41:59 +02:00
* creates new channels
* @param channelArg the name of the topic
* @param passphraseArg the secret thats used for a certain topic.
2018-05-07 18:50:07 +02:00
*/
2018-05-20 00:41:59 +02:00
public static createChannel = (channelNameArg: string, passphraseArg: string) => {
const newChannel = new UniverseChannel(channelNameArg, passphraseArg);
return newChannel;
2018-05-23 23:50:45 +02:00
};
2018-05-20 00:41:59 +02:00
/**
* the name of the channel
*/
public name: string;
2018-04-29 14:17:26 +02:00
/**
2018-05-20 00:41:59 +02:00
* the passphrase for the channel
2018-04-29 14:17:26 +02:00
*/
2018-05-20 00:41:59 +02:00
public passphrase: string;
2018-04-29 14:17:26 +02:00
2018-05-20 00:41:59 +02:00
constructor(channelNameArg: string, passphraseArg: string) {
this.name = channelNameArg;
this.passphrase = passphraseArg;
UniverseChannel.channelStore.add(this);
}
2018-04-13 15:45:48 +02:00
/**
* authenticates a client on the server side
*/
2018-05-20 00:41:59 +02:00
public async authenticateClient(passphraseArg: string): boolean {
return passphraseArg === this.passphrase;
}
2018-04-13 15:45:48 +02:00
}