frame

package
v0.1.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 20, 2024 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Overview

Copyright 2021-2024 antlabs. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021-2024 antlabs. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021-2024 antlabs. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021-2024 antlabs. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var ErrTooLargePayload = errors.New("error:payload too large")

Functions

func WriteFrame

func WriteFrame(fw *fixedwriter.FixedWriter, w io.Writer, payload []byte, fin bool, rsv1 bool, isMask bool, code opcode.Opcode, maskValue uint32) (err error)

fw 是个临时空间,先聚合好数据,再写入 w

func WriteFrameToBytes added in v0.1.1

func WriteFrameToBytes(w *bytes.Buffer, payload []byte, fin bool, rsv1 bool, isMask bool, code opcode.Opcode, maskValue uint32) (err error)

func WriteHeader added in v0.1.4

func WriteHeader(head []byte, fin bool, rsv1, rsv2, rsv3 bool, code opcode.Opcode, payloadLen int, mask bool, maskValue uint32) (have int, err error)

https://datatracker.ietf.org/doc/html/rfc6455#section-5.2 (the most significant bit MUST be 0)

Types

type Frame

type Frame struct {
	FrameHeader
	Payload []byte
}

func ReadFrame

func ReadFrame(r *fixedreader.FixedReader, headArray *[enum.MaxFrameHeaderSize]byte) (f Frame, err error)

func ReadFrameFromReader added in v0.0.8

func ReadFrameFromReader(r io.Reader, headArray *[enum.MaxFrameHeaderSize]byte, buf *[]byte) (f Frame, err error)

func ReadFrameFromWindows added in v0.0.8

func ReadFrameFromWindows(r *fixedreader.FixedReader, headArray *[enum.MaxFrameHeaderSize]byte, multipletimes float32) (f Frame, err error)

type Frame2 added in v0.1.5

type Frame2 struct {
	FrameHeader
	Payload *[]byte
}

func ReadFrameFromReaderV2 added in v0.1.8

func ReadFrameFromReaderV2(r io.Reader, headArray *[enum.MaxFrameHeaderSize]byte, buf *[]byte) (f Frame2, err error)

func ReadFrameFromWindowsV2 added in v0.1.8

func ReadFrameFromWindowsV2(r *fixedreader.FixedReader, headArray *[enum.MaxFrameHeaderSize]byte, multipletimes float32, maxPayload int64) (f Frame2, err error)

func ReadFrameV2 added in v0.1.8

func ReadFrameV2(r *fixedreader.FixedReader, headArray *[enum.MaxFrameHeaderSize]byte) (f Frame2, err error)

type FrameHeader

type FrameHeader struct {
	PayloadLen int64
	MaskKey    uint32
	Mask       bool
	Head       byte
	Opcode     opcode.Opcode
}

func ReadHeader

func ReadHeader(r io.Reader, headArray *[enum.MaxFrameHeaderSize]byte) (h FrameHeader, size int, err error)

func (*FrameHeader) GetFin added in v0.0.10

func (f *FrameHeader) GetFin() bool

func (*FrameHeader) GetRsv1 added in v0.0.10

func (f *FrameHeader) GetRsv1() bool

func (*FrameHeader) GetRsv2 added in v0.0.10

func (f *FrameHeader) GetRsv2() bool

func (*FrameHeader) GetRsv3 added in v0.0.10

func (f *FrameHeader) GetRsv3() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL