mirror of https://github.com/v2ray/v2ray-core
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
344 B
19 lines
344 B
package command
|
|
|
|
var (
|
|
cmdCache = make(map[byte]CommandCreator)
|
|
)
|
|
|
|
func RegisterResponseCommand(id byte, cmdFactory CommandCreator) error {
|
|
cmdCache[id] = cmdFactory
|
|
return nil
|
|
}
|
|
|
|
func CreateResponseCommand(id byte) (Command, error) {
|
|
creator, found := cmdCache[id]
|
|
if !found {
|
|
return nil, ErrorNoSuchCommand
|
|
}
|
|
return creator(), nil
|
|
}
|