Optional id: null | numberOptional initial: Contentimport { Server, Channel } from "rjweb-server"
import { Runtime } from "@rjweb/runtime-bun"
const echo = new Channel<string>()
const server = new Server(Runtime, {
port: 8000
})
server.path('/', (path) => path
.ws('/echo', (ws) => ws
.onOpen((ctr) => {
ctr.printChannel(echo)
})
.onMessage((ctr) => {
echo.send(ctr.rawMessage()) // will send the message to all subscribed sockets
})
)
.http('GET', '/last-echo', (http) => http
.onRequest((ctr) => {
return ctr.print(echo.last())
})
)
)
server.start().then(() => console.log('Server Started!'))
9.0.0
Private dataReadonly idThe ID of the Channel used for publishing
9.0.0
Private listenersProtected onListen for send events on this Channel
9.0.0
Create a new Channel