Provide WsRouter to plugins
This commit is contained in:
@ -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 [
|
||||
{
|
||||
|
Reference in New Issue
Block a user