Elysia WebSocket server adapter for kkrpc
This adapter provides WebSocket server functionality for Elysia applications. It uses Elysia's built-in WebSocket support which is powered by uWebSocket.
import { Elysia } from 'elysia'import { ElysiaWebSocketServerIO, RPCChannel } from 'kkrpc'const app = new Elysia() .ws('/rpc', { open(ws) { const io = new ElysiaWebSocketServerIO(ws) const rpc = new RPCChannel(io, { expose: { greet: (name: string) => `Hello, ${name}!` } }) }, message(ws, message) { // Handle raw messages if needed } }) .listen(3000) Copy
import { Elysia } from 'elysia'import { ElysiaWebSocketServerIO, RPCChannel } from 'kkrpc'const app = new Elysia() .ws('/rpc', { open(ws) { const io = new ElysiaWebSocketServerIO(ws) const rpc = new RPCChannel(io, { expose: { greet: (name: string) => `Hello, ${name}!` } }) }, message(ws, message) { // Handle raw messages if needed } }) .listen(3000)
Get headers from the WebSocket upgrade request
Get query parameters from the WebSocket connection
Get the remote address of the connected client
Get the WebSocket URL from the request
Static
Elysia WebSocket server adapter for kkrpc
This adapter provides WebSocket server functionality for Elysia applications. It uses Elysia's built-in WebSocket support which is powered by uWebSocket.
Example