From 918b220ace85ba210126fec8af3f95a0479f0a1f Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Mon, 8 Jun 2020 08:26:02 +0000 Subject: [PATCH] Connect websocket client to server --- src/app.js | 13 ++++++------- src/app/files/remixDProvider.js | 12 ++++++------ src/app/files/remixd-handle.js | 5 +++-- src/lib/remixd.js | 1 + 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/app.js b/src/app.js index 767f487ed6..0a0194d111 100644 --- a/src/app.js +++ b/src/app.js @@ -143,18 +143,17 @@ class App { registry.put({api: config, name: 'config'}) // load file system - self.appManager = new RemixAppManager({}) self._components.filesProviders = {} self._components.filesProviders['browser'] = new FileProvider('browser') registry.put({api: self._components.filesProviders['browser'], name: 'fileproviders/browser'}) - // var remixd = new Remixd(65520) - // registry.put({api: remixd, name: 'remixd'}) - // remixd.event.register('system', (message) => { - // if (message.error) toolTip(message.error) - // }) + var remixd = new Remixd(65520) + registry.put({api: remixd, name: 'remixd'}) + remixd.event.register('system', (message) => { + if (message.error) toolTip(message.error) + }) - self._components.filesProviders['localhost'] = new RemixDProvider(self.appManager) + self._components.filesProviders['localhost'] = new RemixDProvider(remixd, self.appManager) registry.put({api: self._components.filesProviders['localhost'], name: 'fileproviders/localhost'}) registry.put({api: self._components.filesProviders, name: 'fileproviders'}) diff --git a/src/app/files/remixDProvider.js b/src/app/files/remixDProvider.js index d9257438fb..1ab5e78a94 100644 --- a/src/app/files/remixDProvider.js +++ b/src/app/files/remixDProvider.js @@ -17,9 +17,9 @@ module.exports = class RemixDProvider { var remixdEvents = ['connecting', 'connected', 'errored', 'closed'] remixdEvents.forEach((value) => { - // remixd.event.register(value, (event) => { - // this.event.trigger(value, [event]) - // }) + remixd.event.register(value, (event) => { + this.event.trigger(value, [event]) + }) }) // remixd.event.register('notified', (data) => { @@ -69,7 +69,7 @@ module.exports = class RemixDProvider { }) } - // @TODO: refactor all `this._appManager.call(....)` uses into `this.remixd[api](...)` + // @TODO: refactor all `this._remixd.call(....)` uses into `this.remixd[api](...)` // where `api = ...`: // this.remixd.read(path, (error, content) => {}) // this.remixd.write(path, content, (error, result) => {}) @@ -182,7 +182,7 @@ module.exports = class RemixDProvider { const unprefixedpath = this.removePrefix(path) const callId = await this._appManager.call('remixd', 'isDirectory', {path: unprefixedpath}) - return await this._appManager.receiveResponse(callId) + return await this._remixd.receiveResponse(callId) } async isFile (path) { @@ -192,7 +192,7 @@ module.exports = class RemixDProvider { } } -function remixapi (appManager, self) { +function remixapi (remixd, self) { const read = (path, callback) => { path = '' + (path || '') path = pathtool.join('./', path) diff --git a/src/app/files/remixd-handle.js b/src/app/files/remixd-handle.js index bbd58d4f3c..3b980c2499 100644 --- a/src/app/files/remixd-handle.js +++ b/src/app/files/remixd-handle.js @@ -21,7 +21,7 @@ var css = csjs` const profile = { name: 'remixd', url: 'ws://127.0.0.1:65520', - methods: ['folderIsReadOnly', 'resolveDirectory', 'get', 'exists', 'isFile'], + methods: ['folderIsReadOnly'], events: [], description: 'Using Remixd daemon, allow to access file system', kind: 'other', @@ -43,7 +43,8 @@ export class RemixdHandle extends WebsocketPlugin { }) } - activate () { + async activate () { + await super.activate() this.connectToLocalhost() } diff --git a/src/lib/remixd.js b/src/lib/remixd.js index db789fc994..0fdb7fdb47 100644 --- a/src/lib/remixd.js +++ b/src/lib/remixd.js @@ -106,6 +106,7 @@ class Remixd { reject(error) return } + console.log('this.socket: ', this.socket) if (this.socket && this.socket.readyState === this.socket.OPEN) { var data = this.format(service, fn, args) this.callbacks[data.id] = callback