Add Addr methods to METADAPT implementations
This commit is contained in:
parent
b514c0d621
commit
9bad4d68f1
12
metadapta.go
12
metadapta.go
@ -46,6 +46,14 @@ func (this *a) Close() error {
|
|||||||
return this.underlying.Close()
|
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) {
|
func (this *a) OpenTrans() (Trans, error) {
|
||||||
this.transLock.Lock()
|
this.transLock.Lock()
|
||||||
defer this.transLock.Unlock()
|
defer this.transLock.Unlock()
|
||||||
@ -85,10 +93,6 @@ func (this *a) sendMessageSafe(trans int64, method uint16, data []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *a) receive() {
|
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() {
|
defer func() {
|
||||||
this.underlying.Close()
|
this.underlying.Close()
|
||||||
this.transLock.Lock()
|
this.transLock.Lock()
|
||||||
|
11
metadaptb.go
11
metadaptb.go
@ -23,6 +23,14 @@ func (this *b) Close() error {
|
|||||||
return this.underlying.Close()
|
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) {
|
func (this *b) OpenTrans() (Trans, error) {
|
||||||
stream, err := this.underlying.OpenStream()
|
stream, err := this.underlying.OpenStream()
|
||||||
if err != nil { return nil, err }
|
if err != nil { return nil, err }
|
||||||
@ -55,7 +63,8 @@ func (trans transB) Receive() (uint16, []byte, error) {
|
|||||||
return decodeMessageB(trans.underlying)
|
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 {
|
type MultiConn interface {
|
||||||
// See documentation for [net.Conn].
|
// See documentation for [net.Conn].
|
||||||
io.Closer
|
io.Closer
|
||||||
|
Loading…
Reference in New Issue
Block a user