iprotocol.go 318 B

1234567891011121314
  1. package nnet
  2. type IPacket interface {
  3. // free the memory if needs
  4. Destroy([]byte)
  5. // if need to close socket after sending this packet
  6. ShouldClose() (bool, int32)
  7. }
  8. type IProtocol interface {
  9. // parse by raw data to a packet
  10. ReadPacket(conn IConn) (IPacket, error)
  11. Serialize(packet IPacket) ([]byte, error)
  12. }