change handler registration
This commit is contained in:
parent
27fc5713cc
commit
3fae8a200a
|
@ -34,7 +34,8 @@ func New(log kitlog.Logger, netInfo network.ServerEndpointDetails, m *roomstate.
|
|||
return h
|
||||
}
|
||||
|
||||
func (h *Handler) Register(mux typemux.HandlerMux, namespace muxrpc.Method) {
|
||||
func (h *Handler) RegisterTunnel(mux typemux.HandlerMux) {
|
||||
var namespace = muxrpc.Method{"tunnel"}
|
||||
mux.RegisterAsync(append(namespace, "isRoom"), typemux.AsyncFunc(h.metadata))
|
||||
mux.RegisterAsync(append(namespace, "ping"), typemux.AsyncFunc(h.ping))
|
||||
|
||||
|
@ -49,3 +50,20 @@ func (h *Handler) Register(mux typemux.HandlerMux, namespace muxrpc.Method) {
|
|||
state: h.state,
|
||||
})
|
||||
}
|
||||
|
||||
func (h *Handler) RegisterRoom(mux typemux.HandlerMux) {
|
||||
var namespace = muxrpc.Method{"room"}
|
||||
mux.RegisterAsync(append(namespace, "metadata"), typemux.AsyncFunc(h.metadata))
|
||||
mux.RegisterAsync(append(namespace, "ping"), typemux.AsyncFunc(h.ping))
|
||||
|
||||
mux.RegisterAsync(append(namespace, "announce"), typemux.AsyncFunc(h.announce))
|
||||
mux.RegisterAsync(append(namespace, "leave"), typemux.AsyncFunc(h.leave))
|
||||
|
||||
mux.RegisterSource(append(namespace, "attendants"), typemux.SourceFunc(h.endpoints))
|
||||
|
||||
mux.RegisterDuplex(append(namespace, "connect"), connectHandler{
|
||||
logger: h.logger,
|
||||
self: h.netInfo.RoomID,
|
||||
state: h.state,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -50,13 +50,13 @@ func (s *Server) initHandlers() {
|
|||
mux.RegisterAsync(muxrpc.Method{"manifest"}, manifest)
|
||||
mux.RegisterAsync(muxrpc.Method{"whoami"}, whoami)
|
||||
|
||||
// register tunnel.connect etc twice (as tunnel.* and room.*)
|
||||
var method = muxrpc.Method{"tunnel"}
|
||||
tunnelHandler.Register(mux, method)
|
||||
// register old room v1 commands
|
||||
tunnelHandler.RegisterTunnel(mux)
|
||||
|
||||
method = muxrpc.Method{"room"}
|
||||
tunnelHandler.Register(mux, method)
|
||||
// register new room v2 commands
|
||||
tunnelHandler.RegisterRoom(mux)
|
||||
|
||||
var method = muxrpc.Method{"room"}
|
||||
mux.RegisterAsync(append(method, "registerAlias"), typemux.AsyncFunc(aliasHandler.Register))
|
||||
mux.RegisterAsync(append(method, "revokeAlias"), typemux.AsyncFunc(aliasHandler.Revoke))
|
||||
|
||||
|
|
|
@ -43,8 +43,8 @@ const manifest manifestHandler = `
|
|||
"announce": "sync",
|
||||
"leave": "sync",
|
||||
"connect": "duplex",
|
||||
"endpoints": "source",
|
||||
"isRoom": "async",
|
||||
"attendants": "source",
|
||||
"metadata": "async",
|
||||
"ping": "sync"
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue