Documentation
¶
Overview ¶
Package serialize provides frame serialization interfaces and implementations.
Package serialize provides binary envelope encoding using wire.FrameEnvelope (wire_frames.proto). ProtoEncoder/ProtoDecoder use standard protobuf wire format; ReadProtoEnvelope reads length-prefixed envelopes from a stream.
Package serialize provides binary frame protobuf encode/decode for frames.
Package serialize provides JSON (and optional protobuf) encoding/decoding for frames.
Package serialize implements binary frame wire encoding/decoding without depending on generated descriptor (avoids init issues when protoc is not available).
Index ¶
- func DecodeByType(typ string, data []byte) (frames.Frame, error)
- func Decoder(data []byte) (frames.Frame, error)
- func Encoder(f frames.Frame) ([]byte, error)
- func ProtoDecode(data []byte) (frames.Frame, error)
- func ProtoDecoder(data []byte) (frames.Frame, error)
- func ProtoEncode(f frames.Frame) ([]byte, error)
- func ProtoEncoder(f frames.Frame) ([]byte, error)
- func ReadProtoEnvelope(r io.Reader) (frames.Frame, error)
- type Envelope
- type JSONSerializer
- type ProtobufSerializer
- type Serializer
- type SerializerWithMessageType
- type SerializerWithSetup
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeByType ¶
DecodeByType decodes the payload into the concrete frame type.
func Encoder ¶
Encoder encodes a Frame to JSON with a type discriminator. Wire format: no trailing newline; returned slice is a copy suitable for sending.
func ProtoDecode ¶
ProtoDecode decodes binary protobuf frame data into a Frame.
func ProtoDecoder ¶
ProtoDecoder decodes a binary envelope (wire.FrameEnvelope) into a Frame.
func ProtoEncode ¶
ProtoEncode encodes a Frame to binary protobuf format (wire-compatible with common frame schemas). Returns nil, nil if the frame type is not serializable in this format.
func ProtoEncoder ¶
ProtoEncoder encodes a Frame to binary envelope format (wire.FrameEnvelope: type + payload). Payload is the JSON-encoded frame body.
Types ¶
type Envelope ¶
type Envelope struct {
Type string `json:"type"`
Data json.RawMessage `json:"data"`
}
Envelope is the JSON envelope for wire format (type + payload).
type JSONSerializer ¶
type JSONSerializer struct{}
JSONSerializer uses the JSON envelope format (type + data).
func (JSONSerializer) Deserialize ¶
func (JSONSerializer) Deserialize(data []byte) (frames.Frame, error)
type ProtobufSerializer ¶
type ProtobufSerializer struct{}
ProtobufSerializer uses binary protobuf frame format. Unserializable frame types are skipped (Serialize returns nil, nil).
func (ProtobufSerializer) Deserialize ¶
func (ProtobufSerializer) Deserialize(data []byte) (frames.Frame, error)
type Serializer ¶
type Serializer interface {
Serialize(f frames.Frame) ([]byte, error)
Deserialize(data []byte) (frames.Frame, error)
}
Serializer converts frames to/from wire format (e.g. JSON envelope or binary protobuf).
type SerializerWithMessageType ¶
type SerializerWithMessageType interface {
Serializer
SerializeWithType(f frames.Frame) (data []byte, binary bool, err error)
}
SerializerWithMessageType is an optional interface. When implemented, SerializeWithType is used instead of Serialize, and the returned binary flag selects WebSocket text vs binary (e.g. Vonage: audio = binary, JSON events = text).
type SerializerWithSetup ¶
type SerializerWithSetup interface {
Setup(start *frames.StartFrame)
}
SerializerWithSetup is an optional interface. When implemented, Setup is called when a StartFrame is received so the serializer can read AudioInSampleRate/AudioOutSampleRate.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package exotel provides Exotel Media Streams WebSocket protocol serializer.
|
Package exotel provides Exotel Media Streams WebSocket protocol serializer. |
|
Package genesys provides Genesys AudioHook WebSocket protocol serializer.
|
Package genesys provides Genesys AudioHook WebSocket protocol serializer. |
|
Package plivo provides Plivo Audio Streaming WebSocket protocol serializer.
|
Package plivo provides Plivo Audio Streaming WebSocket protocol serializer. |
|
Package telnyx provides Telnyx WebSocket protocol serializer.
|
Package telnyx provides Telnyx WebSocket protocol serializer. |
|
Package twilio provides Twilio Media Streams WebSocket protocol serializer.
|
Package twilio provides Twilio Media Streams WebSocket protocol serializer. |
|
Package vonage provides Vonage Audio Connector WebSocket serializer.
|
Package vonage provides Vonage Audio Connector WebSocket serializer. |