Real-time communication (WebSocket, SSE) for v-hono-core framework.
- RFC 6455 compliant WebSocket support
- Server-Sent Events (SSE)
- Streaming responses
- Event-based WebSocket API
- Connection lifecycle management
v install --git https://github.com/v-hono/v-hono-core
v install --git https://github.com/v-hono/v-hono-realtimeimport hono
import hono_realtime
fn main() {
mut app := hono.Hono.new()
app.get('/ws', hono_realtime.upgrade_websocket(fn (c hono.Context) hono_realtime.WSEvents {
return hono_realtime.WSEvents{
on_open: fn (mut ws hono_realtime.WSContext) {
ws.send('Welcome!') or {}
}
on_message: fn (event hono_realtime.WSMessageEvent, mut ws hono_realtime.WSContext) {
ws.send('Echo: ${event.data}') or {}
}
}
}))
app.listen(':3000')
}import hono
import hono_realtime
fn main() {
mut app := hono.Hono.new()
app.get('/sse', fn (mut c hono.Context) http.Response {
return hono_realtime.c_stream_sse(mut c, fn (mut stream hono_realtime.StreamContext) ! {
for i in 0 .. 10 {
stream.write_sse(hono_realtime.SSEEvent{
data: 'Message ${i}'
event: 'update'
})!
stream.sleep(1000)
}
})
})
app.listen(':3000')
}hono- Core framework
MIT