How to use the matrix-js-sdk.default.createClient function in matrix-js-sdk

To help you get started, we’ve selected a few matrix-js-sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github matrix-org / matrix-vr-demo / src / js / components / structures / Client.js View on Github external
_syncClient() {
        const opts = {
            baseUrl: this.homeserver,
            accessToken: this.accessToken,
            userId: this.userId,
            deviceId: this.deviceId,
        };
        this.client = matrixcs.createClient(opts);
        this.client.on('sync', (state, prevState, data) => {
            switch (state) {
                case 'PREPARED':
                    this._debugLog('Sync completed');
                    this.synced = true;
                    this.emit('syncComplete');
                    break;
            }
        });

        this.client.on('RoomMember.membership', (event, member) => {
            const room = this.client.getRoom(member.roomId);
            switch (member.membership) {
                case 'invite':
                    if (member.userId === this.userId) {
                        if (!room || room.getJoinedMembers()
github matrix-org / matrix-vr-demo / src / js / components / structures / Client.js View on Github external
setTimeout(() => {
            if (this.accessToken) {
                this.userId = localStorage.getItem('mxvr_user_id');
                this.deviceId = localStorage.getItem('mxvr_device_id');

                this._debugLog('Logged in successfully');
                if (this._persist) {
                    this._persistCredentials();
                }
                this._syncClient();
                return;
            }
            const loginClient = matrixcs.createClient(this.homeserver);
            let loginPromise;
            if (this.guest) {
                this.username = 'mxvr' + Date.now();
                this._debugLog('Registering guest user:', this.username);
                loginPromise = loginClient.register(
                    this.username,
                    Math.random().toString(36).substring(7),
                    null,
                    {type: 'm.login.dummy'},
                );
            } else {
                this._debugLog('Logging in...');
                loginPromise = loginClient.loginWithPassword(this.username,
                    this.password);
            }
            loginPromise.then((data) => {