Archived
1
0

Provide WsRouter to plugins

This commit is contained in:
Asher
2021-01-20 14:11:08 -06:00
parent fb37473e72
commit 055e0ef9ec
8 changed files with 101 additions and 34 deletions

View File

@ -1,5 +1,8 @@
import * as cs from "code-server"
import * as fspath from "path"
import Websocket from "ws"
const wss = new Websocket.Server({ noServer: true })
export const plugin: cs.Plugin = {
displayName: "Test Plugin",
@ -22,6 +25,16 @@ export const plugin: cs.Plugin = {
return r
},
wsRouter() {
const wr = cs.WsRouter()
wr.ws("/test-app", (req) => {
wss.handleUpgrade(req, req.socket, req.head, (ws) => {
ws.send("hello")
})
})
return wr
},
applications() {
return [
{