Added get config message

master
xSmurf 10 years ago
parent 9f81491fc6
commit 820a31d253

@ -1,6 +1,7 @@
package daemon package daemon
import ( import (
"encoding/json"
"fmt" "fmt"
"os" "os"
"os/signal" "os/signal"
@ -33,6 +34,7 @@ func Main() {
err := runServer( err := runServer(
d.log, d.log,
d.handlePing, d.handlePing,
d.handleGetConfig,
d.handleListProfiles, d.handleListProfiles,
d.handleLaunch, d.handleLaunch,
d.handleListSandboxes, d.handleListSandboxes,
@ -164,6 +166,15 @@ func (d *daemonState) handlePing(msg *PingMsg, m *ipc.Message) error {
return m.Respond(&PingMsg{msg.Data}) return m.Respond(&PingMsg{msg.Data})
} }
func (d *daemonState) handleGetConfig(msg *GetConfigMsg, m *ipc.Message) error {
d.Debug("received get config with data [%s]", msg.Data)
jdata, err := json.Marshal(d.config)
if err != nil {
return m.Respond(&ErrorMsg{err.Error()})
}
return m.Respond(&GetConfigMsg{string(jdata)})
}
func (d *daemonState) handleListProfiles(msg *ListProfilesMsg, m *ipc.Message) error { func (d *daemonState) handleListProfiles(msg *ListProfilesMsg, m *ipc.Message) error {
r := new(ListProfilesResp) r := new(ListProfilesResp)
index := 1 index := 1

@ -16,6 +16,10 @@ type PingMsg struct {
Data string "Ping" Data string "Ping"
} }
type GetConfigMsg struct {
Data string "GetConfig"
}
type ListProfilesMsg struct { type ListProfilesMsg struct {
_ string "ListProfiles" _ string "ListProfiles"
} }
@ -83,6 +87,7 @@ var messageFactory = ipc.NewMsgFactory(
new(PingMsg), new(PingMsg),
new(OkMsg), new(OkMsg),
new(ErrorMsg), new(ErrorMsg),
new(GetConfigMsg),
new(ListProfilesMsg), new(ListProfilesMsg),
new(ListProfilesResp), new(ListProfilesResp),
new(LaunchMsg), new(LaunchMsg),

Loading…
Cancel
Save