iprotocol.go 426 B

1234567891011121314151617181920
  1. package nnet
  2. type IPacket interface {
  3. // serialize to binary format to be sent
  4. Serialize() []byte
  5. // free the memory if needs
  6. Destroy([]byte)
  7. // if need to close socket after sending this packet
  8. ShouldClose() (bool, int32)
  9. }
  10. type IProtocol interface {
  11. // parse by raw data to a packet
  12. ReadPacket(conn IConn) (IPacket, error)
  13. }
  14. type IMiddleware interface {
  15. BeforeSend([]byte) []byte
  16. AfterReceived([]byte) []byte
  17. }