isession.go 609 B

12345678910111213141516171819202122232425262728293031323334
  1. package nnet
  2. import "time"
  3. var (
  4. DEF_SESSION_ID uint64 = 0
  5. RUBBISH_SESSION_ID uint64 = 1
  6. )
  7. type ISession interface {
  8. Do() // session 开始工作
  9. Close(int32) // 停止所有工作
  10. IsClosed() bool
  11. Write(IPacket, time.Duration) error
  12. AWrite(IPacket, time.Duration) error // 异步发送
  13. GetData() interface{} // 辅助数据
  14. SetData(interface{})
  15. UpdateId(uint64) //更新ID
  16. Id() uint64
  17. SetId(uint64)
  18. GetRawConn() IConn
  19. }
  20. type ISessionCallback interface {
  21. OnClosed(ISession, int32)
  22. OnConnected(ISession) (bool, int32)
  23. OnMessage(ISession, IPacket) bool
  24. OnHeartbeat(ISession) bool
  25. }