Connect websocket client to server

uiCheck
ioedeveloper 5 years ago committed by yann300
parent f9fe5010c7
commit a99c0baf73
  1. 13
      src/app.js
  2. 12
      src/app/files/remixDProvider.js
  3. 5
      src/app/files/remixd-handle.js
  4. 1
      src/lib/remixd.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'})

@ -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)

@ -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()
}

@ -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

Loading…
Cancel
Save