Compare commits

...

3 Commits

2 changed files with 13 additions and 0 deletions

View File

@ -37,6 +37,11 @@ func AdaptA(underlying net.Conn, party Party) Conn {
transChan: make(chan *transA),
done: make(chan struct { }),
}
if party == ClientSide {
conn.transID = 1
} else {
conn.transID = -1
}
go conn.receive()
return conn
}
@ -60,6 +65,7 @@ func (this *a) OpenTrans() (Trans, error) {
id := this.transID
this.transID ++
trans := &transA {
parent: this,
id: id,
incoming: usync.NewGate[incomingMessage](),
}

View File

@ -21,3 +21,10 @@ func (option Option[T]) Ok() bool {
func (option Option[T]) Get() (T, bool) {
return (ucontainer.Optional[T])(option).Value()
}
func (option Option[T]) Default(defaul T) T {
if value, ok := option.Get(); ok {
return value
}
return defaul
}