MCPcopy
hub / github.com/netbirdio/netbird / readLoop

Function readLoop

client/wasm/internal/ssh/handlers.go:70–91  ·  view source on GitHub ↗
(client *Client, jsInterface js.Value)

Source from the content-addressed store, hash-verified

68}
69
70func readLoop(client *Client, jsInterface js.Value) {
71 buffer := make([]byte, 4096)
72 for {
73 n, err := client.Read(buffer)
74 if err != nil {
75 if err != io.EOF {
76 logrus.Debugf("SSH read error: %v", err)
77 }
78 if onclose := jsInterface.Get("onclose"); !onclose.IsUndefined() {
79 onclose.Invoke()
80 }
81 client.Close()
82 return
83 }
84
85 if ondata := jsInterface.Get("ondata"); !ondata.IsUndefined() {
86 uint8Array := js.Global().Get("Uint8Array").New(n)
87 js.CopyBytesToJS(uint8Array, buffer[:n])
88 ondata.Invoke(uint8Array)
89 }
90 }
91}

Callers 1

CreateJSInterfaceFunction · 0.70

Calls 6

ReadMethod · 0.65
DebugfMethod · 0.65
GetMethod · 0.65
InvokeMethod · 0.65
CloseMethod · 0.65
NewMethod · 0.65

Tested by

no test coverage detected