Skip to content

一个轻量,高性能使用golang实现的网络框架,使用自定义handler,自定义编解码器 处理网络报文

License

Notifications You must be signed in to change notification settings

StephenFaust/noa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Noa

A network framework

Example

custom handler

type TestChanelHandler struct {
}

func (handler TestChanelHandler) OnMessage(chanel *io.Chanel, data *bytes.Buffer) {
log.Println(string(data.Bytes()))
}

func (handler TestChanelHandler) OnError(chanel *io.Chanel, err error) {
log.Println(err.Error())
}

func (handler TestChanelHandler) OnClose() {
log.Println("connection is closed")
}

client

client := io.NewClient(TestChanelHandler{}, codec.DefaultCodec)

_, chanel := client.Connect("127.0.0.1:10086")

chanel.WriteAndFlush(bytes.NewBuffer([]byte("data")))

server

server := io.NewServer(TestChanelHandler{}, codec.LengthSplitCodec{})

err := server.Listen(10086)

About

一个轻量,高性能使用golang实现的网络框架,使用自定义handler,自定义编解码器 处理网络报文

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages