mirror of
https://github.com/balzack/databag.git
synced 2025-04-23 18:15:19 +00:00
adding websocket class
This commit is contained in:
parent
962bb0937f
commit
e04a085fc4
@ -1,10 +1,14 @@
|
||||
import { DatabagSDK } from '../src/index';
|
||||
import { type SessionParams } from '../src/types';
|
||||
|
||||
import { Connection } from '../src/connection';
|
||||
|
||||
jest.mock('../src/connection');
|
||||
|
||||
test('allocates session correctly', async () => {
|
||||
const sdk = new DatabagSDK(null);
|
||||
const params: SessionParams = { topicBatch: 0, tagBatch: 0, channelTypes: [], pushType: '', deviceToken: '', notifications: [], deviceId: '', version: '', appName: '' };
|
||||
const session = await sdk.login('handle', 'password', 'url', params);
|
||||
const session = await sdk.login('handle', 'password', 'url', null, params);
|
||||
const account = session.getAccount();
|
||||
account.enableNotifications();
|
||||
//expect(r).toBe(5);
|
||||
|
@ -170,3 +170,19 @@ export type ProfileEntity = {
|
||||
node: string,
|
||||
}
|
||||
|
||||
export type Ringing = {
|
||||
cardId: string,
|
||||
callId: string,
|
||||
calleeToken: string,
|
||||
ice: { urls: string, username: string, credential: string }[],
|
||||
}
|
||||
|
||||
export type Revision = {
|
||||
account: number,
|
||||
profile: number,
|
||||
article: number,
|
||||
group: number,
|
||||
channel: number,
|
||||
card: number
|
||||
}
|
||||
|
||||
|
@ -34,11 +34,11 @@ export class DatabagSDK {
|
||||
return new SessionModule(this.store, this.crypto, '', '');
|
||||
}
|
||||
|
||||
public async access(token: string, url: string, params: SessionParams): Promise<Session> {
|
||||
public async access(url: string, token: string, params: SessionParams): Promise<Session> {
|
||||
return new SessionModule(this.store, this.crypto, '', '');
|
||||
}
|
||||
|
||||
public async create(handle: string, password: string, url: string, token: string, params: SessionParams): Promise<Session> {
|
||||
public async create(handle: string, password: string, url: string, token: string | null, params: SessionParams): Promise<Session> {
|
||||
return new SessionModule(this.store, this.crypto, '', '');
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,8 @@ import { StreamModule } from './stream';
|
||||
import { FocusModule } from './focus';
|
||||
import { RingModule } from './ring';
|
||||
|
||||
import { Connection } from './connection';
|
||||
|
||||
import type { Session, SqlStore, WebStore, Crypto, Account, Identity, Contact, Ring, Alias, Attribute, Content, Stream, Focus } from './api';
|
||||
|
||||
export class SessionModule implements Session {
|
||||
@ -20,15 +22,15 @@ export class SessionModule implements Session {
|
||||
private token: string;
|
||||
private url: string;
|
||||
private sync: boolean;
|
||||
|
||||
public account: AccountModule;
|
||||
public identity: IdentityModule;
|
||||
public contact: ContactModule;
|
||||
public alias: AliasModule;
|
||||
public attribute: AttributeModule;
|
||||
public content: ContentModule;
|
||||
public stream: StreamModule;
|
||||
public ring: RingModule;
|
||||
private account: AccountModule;
|
||||
private identity: IdentityModule;
|
||||
private contact: ContactModule;
|
||||
private alias: AliasModule;
|
||||
private attribute: AttributeModule;
|
||||
private content: ContentModule;
|
||||
private stream: StreamModule;
|
||||
private ring: RingModule;
|
||||
private connection: Connection;
|
||||
|
||||
constructor(store: SqlStore | WebStore | null, crypto: Crypto | null, token: string, url: string) {
|
||||
this.store = store;
|
||||
@ -45,6 +47,7 @@ export class SessionModule implements Session {
|
||||
this.content = new ContentModule(token, url, this.setSync, this.account);
|
||||
this.stream = new StreamModule(this.contact, this.content);
|
||||
this.ring = new RingModule();
|
||||
this.connection = new Connection(token, url);
|
||||
}
|
||||
|
||||
public addStatusListener(ev: (status: string) => void): void {
|
||||
@ -64,6 +67,7 @@ export class SessionModule implements Session {
|
||||
}
|
||||
|
||||
public close() {
|
||||
this.connection.close();
|
||||
this.stream.close();
|
||||
this.content.close();
|
||||
this.attribute.close();
|
||||
|
@ -19,12 +19,26 @@ export type Call = {
|
||||
cardId: string,
|
||||
callId: string,
|
||||
calleeToken: string,
|
||||
ice: { urls: string, username: string, credential: string}[],
|
||||
ice?: { urls: string, username: string, credential: string}[],
|
||||
iceUrl: string, // deprecated
|
||||
iceUsername: string, // deprecated
|
||||
icePassword: string, // deprecated
|
||||
}
|
||||
|
||||
export type Revision = {
|
||||
account: number,
|
||||
profile: number,
|
||||
article: number,
|
||||
group: number,
|
||||
channel: number,
|
||||
card: number
|
||||
}
|
||||
|
||||
export type Activity = {
|
||||
revision?: Revision,
|
||||
phone?: Call,
|
||||
}
|
||||
|
||||
export type Channel = {
|
||||
id: string,
|
||||
cardId: string | null,
|
||||
|
Loading…
x
Reference in New Issue
Block a user