@yehn/core
v3.0.5
Published
Yehn for Web's communication core.
Downloads
14
Readme
Yehn
This repository is part of the source code of Yehn. You can find more information at yehn.io or by contacting [email protected].
You can find the published source code at github.com/yehnhq/yehn.
For licensing information, see the attached LICENSE file and the list of third-party licenses at yehn.io/legal/licenses/.
Core
Yehn for Web's communication core.
Example
yarn add @yehn/coreJavaScript (Node.js)
const {Account} = require('@yehn/core');
const account = new Account();
account.on(Account.INCOMING.TEXT_MESSAGE, ({conversation, content}) => {
account.service.conversation.sendTextMessage(conversation, `Echo: ${content}`);
});
account.listen({
clientType: 'temporary',
email: '[email protected]',
password: 'secret',
});TypeScript
import {Account} from '@yehn/core';
import {PayloadBundle} from '@yehn/core/dist/commonjs/cryptography/';
import {ClientType} from '@yehn/api-client/dist/commonjs/client/';
import {LoginData} from '@yehn/api-client/dist/commonjs/auth/';
const account: Account = new Account();
const login: LoginData = {
clientType: ClientType.TEMPORARY,
email: '[email protected]',
password: 'secret',
};
account.on(Account.INCOMING.TEXT_MESSAGE, (data: PayloadBundle) => {
account.service.conversation.sendTextMessage(data.conversation, data.content);
});
account.listen(login).catch(error => {
console.error(error.stack);
return process.exit(1);
});