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
|
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, "isRoom"), typemux.AsyncFunc(h.metadata))
|
||||||
mux.RegisterAsync(append(namespace, "ping"), typemux.AsyncFunc(h.ping))
|
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,
|
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{"manifest"}, manifest)
|
||||||
mux.RegisterAsync(muxrpc.Method{"whoami"}, whoami)
|
mux.RegisterAsync(muxrpc.Method{"whoami"}, whoami)
|
||||||
|
|
||||||
// register tunnel.connect etc twice (as tunnel.* and room.*)
|
// register old room v1 commands
|
||||||
var method = muxrpc.Method{"tunnel"}
|
tunnelHandler.RegisterTunnel(mux)
|
||||||
tunnelHandler.Register(mux, method)
|
|
||||||
|
|
||||||
method = muxrpc.Method{"room"}
|
// register new room v2 commands
|
||||||
tunnelHandler.Register(mux, method)
|
tunnelHandler.RegisterRoom(mux)
|
||||||
|
|
||||||
|
var method = muxrpc.Method{"room"}
|
||||||
mux.RegisterAsync(append(method, "registerAlias"), typemux.AsyncFunc(aliasHandler.Register))
|
mux.RegisterAsync(append(method, "registerAlias"), typemux.AsyncFunc(aliasHandler.Register))
|
||||||
mux.RegisterAsync(append(method, "revokeAlias"), typemux.AsyncFunc(aliasHandler.Revoke))
|
mux.RegisterAsync(append(method, "revokeAlias"), typemux.AsyncFunc(aliasHandler.Revoke))
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,8 @@ const manifest manifestHandler = `
|
||||||
"announce": "sync",
|
"announce": "sync",
|
||||||
"leave": "sync",
|
"leave": "sync",
|
||||||
"connect": "duplex",
|
"connect": "duplex",
|
||||||
"endpoints": "source",
|
"attendants": "source",
|
||||||
"isRoom": "async",
|
"metadata": "async",
|
||||||
"ping": "sync"
|
"ping": "sync"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue