mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-08 19:38:51 +01:00
minor changes to ws
This commit is contained in:
parent
6f7a883cfd
commit
a5fedb3668
@ -15,6 +15,7 @@ import (
|
|||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
|
|
||||||
"github.com/scripthaus-dev/sh2-runner/pkg/base"
|
"github.com/scripthaus-dev/sh2-runner/pkg/base"
|
||||||
|
"github.com/scripthaus-dev/sh2-runner/pkg/cmdtail"
|
||||||
"github.com/scripthaus-dev/sh2-runner/pkg/packet"
|
"github.com/scripthaus-dev/sh2-runner/pkg/packet"
|
||||||
"github.com/scripthaus-dev/sh2-runner/pkg/shexec"
|
"github.com/scripthaus-dev/sh2-runner/pkg/shexec"
|
||||||
"github.com/scripthaus-dev/sh2-server/pkg/sstore"
|
"github.com/scripthaus-dev/sh2-server/pkg/sstore"
|
||||||
@ -34,6 +35,7 @@ var GlobalRunnerProc *RunnerProc
|
|||||||
type WsConnType struct {
|
type WsConnType struct {
|
||||||
Id string
|
Id string
|
||||||
Shell *wsshell.WSShell
|
Shell *wsshell.WSShell
|
||||||
|
Tailer *cmdtail.Tailer
|
||||||
}
|
}
|
||||||
|
|
||||||
type RunnerProc struct {
|
type RunnerProc struct {
|
||||||
@ -71,14 +73,13 @@ func HandleWs(w http.ResponseWriter, r *http.Request) {
|
|||||||
wsConn.Shell.Conn.Close()
|
wsConn.Shell.Conn.Close()
|
||||||
}()
|
}()
|
||||||
fmt.Printf("WebSocket opened %s\n", shell.RemoteAddr)
|
fmt.Printf("WebSocket opened %s\n", shell.RemoteAddr)
|
||||||
for msg := range shell.ReadChan {
|
for msgBytes := range shell.ReadChan {
|
||||||
jmsg := map[string]interface{}{}
|
pk, err := packet.ParseJsonPacket(msgBytes)
|
||||||
err = json.Unmarshal(msg, &jmsg)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("error unmarshalling ws message: %v\n", err)
|
fmt.Printf("error unmarshalling ws message: %v\n", err)
|
||||||
break
|
continue
|
||||||
}
|
}
|
||||||
fmt.Printf("got ws message: %v\n", jmsg)
|
fmt.Printf("got ws message: %v\n", pk)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user