Browse Source
Merge pull request #111 from elvin-zheng/master
Merge pull request #111 from elvin-zheng/master
[pref]: change packet IO modulemaster
刘丹冰
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 70 additions and 44 deletions
-
8ziface/ipacket.go
-
1ziface/iserver.go
-
15znet/connection.go
-
56znet/connmanager.go
-
6znet/datapack.go
-
12znet/options.go
-
16znet/server.go
@ -0,0 +1,8 @@ |
|||
package ziface |
|||
|
|||
|
|||
type Packet interface { |
|||
Unpack(binaryData []byte) (IMessage, error) |
|||
Pack(msg IMessage) ([]byte, error) |
|||
GetHeadLen() uint32 |
|||
} |
@ -0,0 +1,12 @@ |
|||
package znet |
|||
|
|||
import "github.com/aceld/zinx/ziface" |
|||
|
|||
type Option func(s *Server) |
|||
|
|||
// 只要实现Packet 接口可自由实现数据包解析格式,如果没有则使用默认解析格式
|
|||
func WithPacket(pack ziface.Packet) Option { |
|||
return func(s *Server) { |
|||
s.packet = pack |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue