Add Addr methods to METADAPT implementations

This commit is contained in:
Sasha Koshka 2025-01-22 16:57:06 -05:00
parent b514c0d621
commit 9bad4d68f1
2 changed files with 18 additions and 5 deletions

View File

@ -46,6 +46,14 @@ func (this *a) Close() error {
return this.underlying.Close()
}
func (this *a) LocalAddr() net.Addr {
return this.underlying.LocalAddr()
}
func (this *a) RemoteAddr() net.Addr {
return this.underlying.RemoteAddr()
}
func (this *a) OpenTrans() (Trans, error) {
this.transLock.Lock()
defer this.transLock.Unlock()
@ -85,10 +93,6 @@ func (this *a) sendMessageSafe(trans int64, method uint16, data []byte) error {
}
func (this *a) receive() {
// TODO: multiplex receiving
// if a received transaction has a malformed ID, reject it here and
// cause the connection to fail
// at the end of this function, close all incoming channels
defer func() {
this.underlying.Close()
this.transLock.Lock()

View File

@ -23,6 +23,14 @@ func (this *b) Close() error {
return this.underlying.Close()
}
func (this *b) LocalAddr() net.Addr {
return this.underlying.LocalAddr()
}
func (this *b) RemoteAddr() net.Addr {
return this.underlying.RemoteAddr()
}
func (this *b) OpenTrans() (Trans, error) {
stream, err := this.underlying.OpenStream()
if err != nil { return nil, err }
@ -55,7 +63,8 @@ func (trans transB) Receive() (uint16, []byte, error) {
return decodeMessageB(trans.underlying)
}
// MultiConn represens a multiplexed stream-oriented transport for use in [B].
// MultiConn represens a multiplexed stream-oriented transport for use in
// [AdaptB].
type MultiConn interface {
// See documentation for [net.Conn].
io.Closer