You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
package server
import (
"github.com/noahlann/nnet/internal/connection"
ctxpkg "github.com/noahlann/nnet/pkg/context"
)
// connectionAdapter 连接适配器, 将ConnectionInterface适配为Context.Connection
type connectionAdapter struct {
connInterface connection . ConnectionInterface
}
// ID 实现Context.Connection接口
func ( a * connectionAdapter ) ID ( ) string {
return a . connInterface . ID ( )
}
// RemoteAddr 实现Context.Connection接口
func ( a * connectionAdapter ) RemoteAddr ( ) string {
return a . connInterface . RemoteAddr ( )
}
// LocalAddr 实现Context.Connection接口
func ( a * connectionAdapter ) LocalAddr ( ) string {
return a . connInterface . LocalAddr ( )
}
// Write 实现Context.Connection接口
func ( a * connectionAdapter ) Write ( data [ ] byte ) error {
return a . connInterface . Write ( data )
}
// Close 实现Context.Connection接口
func ( a * connectionAdapter ) Close ( ) error {
return a . connInterface . Close ( )
}
// toContextConnection 将ConnectionInterface转换为Context.Connection
func toContextConnection ( connInterface connection . ConnectionInterface ) ctxpkg . Connection {
return & connectionAdapter { connInterface : connInterface }
}