aboutsummaryrefslogtreecommitdiffstats
path: root/lib/agent/apiv1-exec.go
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-11-24 01:14:30 +0100
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-11-24 01:37:24 +0100
commit4d843d2bde236ec23810d0904dfb8aebbc53a37b (patch)
tree84c01452f01620cedb7bf6bcb608a0eade82161b /lib/agent/apiv1-exec.go
parent38c0c21a969e621c725245ce91c78e77076c5ce7 (diff)
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 <sebastien.douheret@iot.bzh>
Diffstat (limited to 'lib/agent/apiv1-exec.go')
-rw-r--r--lib/agent/apiv1-exec.go18
1 files changed, 11 insertions, 7 deletions
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])