MCPcopy Index your code
hub / github.com/1Panel-dev/KubePi / handleTerminalSession

Function handleTerminalSession

pkg/terminal/shell.go:191–222  ·  view source on GitHub ↗

handleTerminalSession is Called by net/http for any new /api/sockjs connections

(session sockjs.Session)

Source from the content-addressed store, hash-verified

189
190// handleTerminalSession is Called by net/http for any new /api/sockjs connections
191func handleTerminalSession(session sockjs.Session) {
192 var (
193 buf string
194 err error
195 msg TerminalMessage
196 terminalSession TerminalSession
197 )
198
199 if buf, err = session.Recv(); err != nil {
200 log.Printf("handleTerminalSession: can't Recv: %v", err)
201 return
202 }
203
204 if err = json.Unmarshal([]byte(buf), &msg); err != nil {
205 log.Printf("handleTerminalSession: can't UnMarshal (%v): %s", err, buf)
206 return
207 }
208
209 if msg.Op != "bind" {
210 log.Printf("handleTerminalSession: expected 'bind' message, got: %s", buf)
211 return
212 }
213
214 if terminalSession = TerminalSessions.Get(msg.SessionID); terminalSession.Id == "" {
215 log.Printf("handleTerminalSession: can't find session '%s'", msg.SessionID)
216 return
217 }
218
219 terminalSession.sockJSSession = session
220 TerminalSessions.Set(msg.SessionID, terminalSession)
221 terminalSession.Bound <- nil
222}
223
224// CreateAttachHandler is called from main for /api/sockjs
225func CreateAttachHandler(path string) http.Handler {

Callers

nothing calls this directly

Calls 2

GetMethod · 0.65
SetMethod · 0.45

Tested by

no test coverage detected