mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-11-09 19:58:45 -05:00
19 lines
344 B
Go
19 lines
344 B
Go
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
|
|
}
|