mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-11-02 17:27:50 -04: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
|
|
}
|