Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

Commit

Permalink
fix registering to ws
Browse files Browse the repository at this point in the history
  • Loading branch information
yann300 committed Feb 3, 2021
1 parent 0fefc87 commit 05ea4b2
Show file tree
Hide file tree
Showing 3 changed files with 2,921 additions and 1,467 deletions.
45 changes: 36 additions & 9 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const remixd = require('remixd')
const remixd = require('@remix-project/remixd')
const path = require('path')
const os = require('os')
const IPFS = require('ipfs')
Expand All @@ -7,18 +7,19 @@ const IPFSGateway = require('ipfs-http-gateway')
const { version } = require('./package.json')
const applicationMenu = require('./applicationMenu')
const { app, BrowserWindow, shell } = require('electron')
const { AppManager, registerPackageProtocol } = require('@philipplgh/electron-app-manager')
const { AppManager, registerPackageProtocol } = require('electron-app-manager')

const cacheDir = path.join(os.homedir(), '.cache_remix_ide')
registerPackageProtocol(cacheDir)

const remixIdeUrl = 'package://6fd22d6fe5549ad4c4d8fd3ca0b7816b.mod'

console.log('running', version)
const updater = new AppManager({
repository: 'https://github.com/ethereum/remix-desktop',
auto: true,
electron: true
})
const sharedFolderClient = new remixd.services.sharedFolder()

function createWindow () {
let win = new BrowserWindow({
Expand All @@ -29,7 +30,6 @@ function createWindow () {
},
icon: path.join(__dirname, 'build/icon.png')
})
applicationMenu(sharedFolderClient)
win.webContents.on('new-window', function(e, url) {
e.preventDefault();
shell.openExternal(url);
Expand Down Expand Up @@ -65,16 +65,43 @@ app.on('ready', () => {
ipfsStart()
})

const sharedFolderClient = new remixd.services.sharedFolder()
const services = {
git: () => new servicesList.GitClient(),
folder: () => {
sharedFolderClient.options.customApi = {}
return sharedFolderClient
}
}

applicationMenu(sharedFolderClient)

const ports = {
git: 65521,
folder: 65520
}

function startService (service, callback) {
try {
const socket = new remixd.Websocket(ports[service], { remixIdeUrl }, () => services[service]())
socket.start(callback)
} catch (e) {
console.error(e)
}
}

let remixdStart = () => {
const remixIdeUrl = 'package://6fd22d6fe5549ad4c4d8fd3ca0b7816b.mod'
console.log('start shared folder service')
try {
const websocketHandler = new remixd.Websocket(65520, { remixIdeUrl }, sharedFolderClient)

websocketHandler.start((ws) => {
console.log('set websocket')
startService('folder', (ws, sharedFolderClient) => {
sharedFolderClient.setWebSocket(ws)
})

/*
startService('git', (ws, sharedFolderClient) => {
sharedFolderClient.setWebSocket(ws)
sharedFolderClient.sharedFolder(program.sharedFolder, program.readOnly || false)
})*/
} catch (error) {
throw new Error(error)
}
Expand Down
Loading

0 comments on commit 05ea4b2

Please sign in to comment.