transaction.go 383 B

1234567891011121314151617181920212223
  1. package udp
  2. import "math/rand"
  3. func RandomTransactionId() TransactionId {
  4. return TransactionId(rand.Uint32())
  5. }
  6. type TransactionResponseHandler func(dr DispatchedResponse)
  7. type Transaction struct {
  8. id int32
  9. d *Dispatcher
  10. h TransactionResponseHandler
  11. }
  12. func (t *Transaction) Id() TransactionId {
  13. return t.id
  14. }
  15. func (t *Transaction) End() {
  16. t.d.forgetTransaction(t.id)
  17. }