MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / WritePacket

Function WritePacket

pkg/util/packetparser/packetparser.go:74–89  ·  view source on GitHub ↗
(output io.Writer, packet []byte)

Source from the content-addressed store, hash-verified

72}
73
74func WritePacket(output io.Writer, packet []byte) error {
75 if len(packet) < 2 {
76 return nil
77 }
78 if packet[0] != '{' || packet[len(packet)-1] != '}' {
79 return fmt.Errorf("invalid packet, must start with '{' and end with '}'")
80 }
81 fullPacket := make([]byte, 0, len(packet)+5)
82 // we add the extra newline to make sure the ## appears at the beginning of the line
83 // since writer isn't buffered, we want to send this all at once
84 fullPacket = append(fullPacket, '\n', '#', '#', 'N')
85 fullPacket = append(fullPacket, packet...)
86 fullPacket = append(fullPacket, '\n')
87 _, err := output.Write(fullPacket)
88 return err
89}

Callers 3

SetupPacketRpcClientFunction · 0.92
HandleStdIOClientFunction · 0.92
serverRunRouterFunction · 0.92

Calls 1

WriteMethod · 0.65

Tested by

no test coverage detected