Note
This is purely for internal use! Please don't depend on this library in your own code, we don't make any compatibility/API stability guarantees!
Length-prefixed framing for QUIC & TCP streams, compatible with the TypeScript implementation used in the SDK. Uses protobuf-style varint encoding of length prefix markers.
Add module:
go get github.com/hardpointlabs/framerLayer it on top of your io.Reader / io.Writer:
import (
// ...
"github.com/hardpointlabs/lpstream"
)
conn, _ := net.DialTimeout("tcp", "test-server:8124", 10*time.Second)
defer conn.Close()
encoder := lpstream.NewEncoder(conn)
decoder := lpstream.NewDecoder(conn)
// or use the codec type if you have a bidirectional stream
codec := lpstream.NewFrameCodec(conn)
encoder.WriteFrame([]byte("Hello, stream!"))
msg := decoder.ReadFrame()
// e.t.c...