From 4d843d2bde236ec23810d0904dfb8aebbc53a37b Mon Sep 17 00:00:00 2001 From: Sebastien Douheret Date: Fri, 24 Nov 2017 01:14:30 +0100 Subject: New dashboard improvements. - add build buttons - add build settings support and backup into project clientData - improved async alert - fixed project dropdown Signed-off-by: Sebastien Douheret --- lib/agent/apiv1-exec.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'lib/agent/apiv1-exec.go') diff --git a/lib/agent/apiv1-exec.go b/lib/agent/apiv1-exec.go index c199267..3cb4d23 100644 --- a/lib/agent/apiv1-exec.go +++ b/lib/agent/apiv1-exec.go @@ -5,15 +5,13 @@ import ( "io/ioutil" "net/http" + "github.com/franciscocpg/reflectme" "github.com/gin-gonic/gin" "github.com/iotbzh/xds-agent/lib/apiv1" common "github.com/iotbzh/xds-common/golib" uuid "github.com/satori/go.uuid" ) -var execCmdID = 1 -var fwdFuncID []uuid.UUID - // ExecCmd executes remotely a command func (s *APIService) execCmd(c *gin.Context) { s._execRequest("/exec", c) @@ -81,6 +79,7 @@ func (s *APIService) _execRequest(cmd string, c *gin.Context) { apiv1.ExecInferiorOutEvent, } + var fwdFuncID []uuid.UUID for _, evName := range evtList { evN := evName fwdFunc := func(pData interface{}, evData interface{}) error { @@ -92,6 +91,9 @@ func (s *APIService) _execRequest(cmd string, c *gin.Context) { return nil } + // Add sessionID to event Data + reflectme.SetField(evData, "sessionID", sid) + // Forward event to Client/Dashboard (*so).Emit(evN, evData) return nil @@ -110,15 +112,17 @@ func (s *APIService) _execRequest(cmd string, c *gin.Context) { evN := apiv1.ExecExitEvent sid := pData.(string) + // Add sessionID to event Data + reflectme.SetField(evData, "sessionID", sid) + // IO socket can be nil when disconnected so := s.sessions.IOSocketGet(sid) - if so == nil { + if so != nil { + (*so).Emit(evN, evData) + } else { s.Log.Infof("%s not emitted: WS closed (sid:%s)", evN, sid) - return nil } - (*so).Emit(evN, evData) - // cleanup listener for i, evName := range evtList { svr.EventOff(evName, fwdFuncID[i]) -- cgit 1.2.3-korg