baseio

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package baseio micserver 中网络连接的基础IO接口实现,支持自定义网络协议

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Protocal

type Protocal interface {
	// 读数据
	DoRead(reader io.ReadWriter, state interface{},
		data []byte) (int, interface{}, error)
	// 写数据
	DoWrite(writer io.ReadWriter, state interface{},
		toData []byte) (int, interface{}, error)
}

Protocal 网络层协议接口

type Worker

type Worker struct {
	// contains filtered or unexported fields
}

Worker 协议处理工作

func (*Worker) HookProtocal

func (w *Worker) HookProtocal(p Protocal)

HookProtocal 设置网络层协议工作

func (*Worker) Init

func (w *Worker) Init(rw io.ReadWriter)

Init 初始化网络基础IO

func (*Worker) Read

func (w *Worker) Read(toData []byte) (int, error)

Read 从io中读数据,如果自定义了网络层协议,则使用自定义协议读取,否则默认TCP协议

func (*Worker) Write

func (w *Worker) Write(data []byte) (int, error)

Write 向io中写数据,如果自定义了网络层协议,则使用自定义协议写入,否则默认TCP协议

Jump to

Keyboard shortcuts

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