Skip to content

Instantly share code, notes, and snippets.

@GrandSchtroumpf
Created November 4, 2019 10:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GrandSchtroumpf/ae7e02d8729300f32cb240e273311a5c to your computer and use it in GitHub Desktop.
Save GrandSchtroumpf/ae7e02d8729300f32cb240e273311a5c to your computer and use it in GitHub Desktop.
Exemple using plugin-ws
const pluginWs = require('@remixproject/plugin-ws')
const express = require('express')
const ws = require('express-ws')
const bodyParser = require('body-parser');
const cors = require('cors');
const app = express()
ws(app)
app.use(bodyParser.urlencoded({extended: true}))
app.use(bodyParser.json());
app.use(cors({origin: true}));
app.options('*', cors());
app.ws('/', async (socket) => {
const client = pluginWs.createWebsocketClient(socket)
await client.onload()
await client.call('fileManager', 'setFile', 'browser/hello.txt', 'Hello World')
})
const port = 65520;
app.listen(port, () => console.log(`Remixd server started on port ${port}`));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment