29 lines
516 B
Go
29 lines
516 B
Go
package main
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"git.loafle.net/overflow/overflow_service_websocket/protocol/jsonrpc"
|
|
"git.loafle.net/overflow/overflow_service_websocket/server"
|
|
)
|
|
|
|
var (
|
|
host = "localhost:8080"
|
|
)
|
|
|
|
func main() {
|
|
ws := server.New(server.Options{})
|
|
ws.RegistProtocol("jsonrpc", jsonrpc.NewHandler())
|
|
ws.OnConnection(func(c server.Client) {
|
|
c.OnDisconnect(func(Client) {
|
|
|
|
})
|
|
})
|
|
|
|
http.HandleFunc("/ws", ws.HTTPHandler())
|
|
|
|
// ws.OnConnection(handleWebsocketConnection)
|
|
|
|
http.ListenAndServe(host, nil)
|
|
}
|