Created
November 4, 2019 10:55
-
-
Save GrandSchtroumpf/ae7e02d8729300f32cb240e273311a5c to your computer and use it in GitHub Desktop.
Exemple using plugin-ws
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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