mirror of
https://github.com/mumble-voip/grumble.git
synced 2025-12-19 21:59:59 -08:00
Check for server existance in ctlrpc.
This commit is contained in:
parent
c785c45166
commit
cfa9172e69
1 changed files with 22 additions and 4 deletions
26
ctlrpc.go
26
ctlrpc.go
|
|
@ -13,12 +13,22 @@ type ControlRPC struct {
|
|||
}
|
||||
|
||||
// Start a server
|
||||
func (c *ControlRPC) Start(in *int, out *int) os.Error {
|
||||
func (c *ControlRPC) Start(Id int64, out *int) os.Error {
|
||||
server, exists := servers[Id]
|
||||
if !exists {
|
||||
return os.NewError("no such server")
|
||||
}
|
||||
_ = server
|
||||
return nil
|
||||
}
|
||||
|
||||
// Stop a server
|
||||
func (c *ControlRPC) Stop(in *int, out *int) os.Error {
|
||||
func (c *ControlRPC) Stop(Id int64, out *int) os.Error {
|
||||
server, exists := servers[Id]
|
||||
if !exists {
|
||||
return os.NewError("no such server")
|
||||
}
|
||||
_ = server
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -30,7 +40,11 @@ type ConfigValue struct {
|
|||
|
||||
// Set a config value
|
||||
func (c *ControlRPC) SetConfig(in *ConfigValue, out *ConfigValue) os.Error {
|
||||
servers[in.Id].cfg.Set(in.Key, in.Value)
|
||||
server, exists := servers[in.Id]
|
||||
if !exists {
|
||||
return os.NewError("no such server")
|
||||
}
|
||||
server.cfg.Set(in.Key, in.Value)
|
||||
out.Id = in.Id
|
||||
out.Key = in.Key
|
||||
out.Value = in.Value
|
||||
|
|
@ -39,8 +53,12 @@ func (c *ControlRPC) SetConfig(in *ConfigValue, out *ConfigValue) os.Error {
|
|||
|
||||
// Get a config value
|
||||
func (c *ControlRPC) GetConfig(in *ConfigValue, out *ConfigValue) os.Error {
|
||||
server, exists := servers[in.Id]
|
||||
if !exists {
|
||||
return os.NewError("no such server")
|
||||
}
|
||||
out.Id = in.Id
|
||||
out.Key = in.Key
|
||||
out.Value = servers[in.Id].cfg.StringValue(in.Key)
|
||||
out.Value = server.cfg.StringValue(in.Key)
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue