feat: 添加串口连接类型参数。

main v1.1.3
NoahLan 1 year ago
parent ba3df17bc4
commit 3bc9c095df

@ -34,8 +34,9 @@ const (
type ConnType int type ConnType int
const ( const (
ConnTypeTCP ConnType = iota // TCP connection ConnTypeTCP ConnType = iota // TCP connection
ConnTypeWS // Websocket connection ConnTypeWS // Websocket connection
ConnTypeSerial // Websocket connection
) )
type ( type (
@ -102,9 +103,13 @@ func NewConnection(
chSend: make(chan PendingMessage, 128), chSend: make(chan PendingMessage, 128),
chWrite: make(chan []byte, 128), chWrite: make(chan []byte, 128),
} }
_, ok := conn.(*WSConn) if _, ok := conn.(*WSConn); ok {
if ok {
r.typ = ConnTypeWS r.typ = ConnTypeWS
return r
}
if _, ok := conn.(*SerialConn); ok {
r.typ = ConnTypeSerial
return r
} }
return r return r
} }

Loading…
Cancel
Save