protocols

package
v0.0.0-...-67ca109 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2020 License: Apache-2.0 Imports: 2 Imported by: 4

Documentation

Overview

frame protocol

Protocol the interface of protocol, include three method, you can define custom protocol through implement three method.

text protocol.

webSocket protocol

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Frame

type Frame struct {
}

Frame frame struct.

func NewFrameProtocol

func NewFrameProtocol() *Frame

NewFrameProtocol.

func (*Frame) Decode

func (t *Frame) Decode(buffer []byte) []byte

Decode decode the buffer.

func (*Frame) Encode

func (t *Frame) Encode(buffer []byte) interface{}

Encode encode the buffer, the type of return value is []byte.

func (*Frame) Input

func (t *Frame) Input(buffer []byte, maxPackageSize int) interface{}

Input check the integrity of the package.

type Protocol

type Protocol interface {
	// Encode encode package before send to client.
	// The type of return is different for each protocol.
	Encode(data []byte) interface{}
	// Decode decode package and emit.
	Decode(recvBuffer []byte) []byte
	// Input check the integrity of package.
	// if return the value of bool, close connection, indicates that the package is greater than MaxPackageSize,
	// else if return 0, the package is not a integrity package, continue to receive.
	Input(recvBuffer []byte, maxPackageSize int) interface{}
}

type Text

type Text struct {
}

Text text struct.

func NewTextProtocol

func NewTextProtocol() *Text

NewTextProtocol.

func (*Text) Decode

func (t *Text) Decode(buffer []byte) []byte

Decode decode the buffer.

func (*Text) Encode

func (t *Text) Encode(buffer []byte) interface{}

Encode encode the buffer, the type of return value is []byte.

func (*Text) Input

func (t *Text) Input(buffer []byte, maxPackageSize int) interface{}

Input check the integrity of the package.

Directories

Path Synopsis
http this simple http protocol.
http this simple http protocol.

Jump to

Keyboard shortcuts

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