From 862014bd824a61d9b2318ca6979228eab246f576 Mon Sep 17 00:00:00 2001 From: sawka Date: Thu, 16 Jun 2022 15:51:41 -0700 Subject: [PATCH] add windowid --- cmd/main-server.go | 3 ++- pkg/sstore/sstore.go | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cmd/main-server.go b/cmd/main-server.go index 3bb882758..736d35f0c 100644 --- a/cmd/main-server.go +++ b/cmd/main-server.go @@ -141,6 +141,7 @@ func WriteJsonSuccess(w http.ResponseWriter, data interface{}) { type runCommandParams struct { SessionId string `json:"sessionid"` + WindowId string `json:"windowid"` Command string `json:"command"` } @@ -174,7 +175,7 @@ func HandleRunCommand(w http.ResponseWriter, r *http.Request) { WriteJsonError(w, fmt.Errorf("invalid emtpty command")) return } - rtnLine := sstore.MakeNewLineCmd(commandStr) + rtnLine := sstore.MakeNewLineCmd(params.SessionId, params.WindowId, commandStr) runPacket := packet.MakeRunPacket() runPacket.SessionId = params.SessionId runPacket.CmdId = rtnLine.CmdId diff --git a/pkg/sstore/sstore.go b/pkg/sstore/sstore.go index 1234a8626..b9a4c417e 100644 --- a/pkg/sstore/sstore.go +++ b/pkg/sstore/sstore.go @@ -12,6 +12,8 @@ const LineTypeCmd = "cmd" const LineTypeText = "text" type LineType struct { + SessionId string `json:"sessionid"` + WindowId string `json:"windowid"` LineId int `json:"lineid"` Ts int64 `json:"ts"` UserId string `json:"userid"` @@ -22,8 +24,10 @@ type LineType struct { CmdRemote string `json:"cmdremote,omitempty"` } -func MakeNewLineCmd(cmdText string) *LineType { +func MakeNewLineCmd(sessionId string, windowId string, cmdText string) *LineType { rtn := &LineType{} + rtn.SessionId = sessionId + rtn.WindowId = windowId rtn.LineId = NextLineId NextLineId++ rtn.Ts = time.Now().UnixMilli() @@ -34,8 +38,10 @@ func MakeNewLineCmd(cmdText string) *LineType { return rtn } -func MakeNewLineText(text string) *LineType { +func MakeNewLineText(sessionId string, windowId string, text string) *LineType { rtn := &LineType{} + rtn.SessionId = sessionId + rtn.WindowId = windowId rtn.LineId = NextLineId NextLineId++ rtn.Ts = time.Now().UnixMilli()