mirror of
https://github.com/lkmio/lkm.git
synced 2025-10-06 07:36:56 +08:00
refactor: gb28181仅支持多端口推流, 提升代码健壮性
This commit is contained in:
@@ -18,8 +18,10 @@ type StreamServer[T any] struct {
|
||||
}
|
||||
|
||||
func (s *StreamServer[T]) OnConnected(conn net.Conn) []byte {
|
||||
log.Sugar.Debugf("%s连接 conn:%s", s.SourceType.String(), conn.RemoteAddr().String())
|
||||
conn.(*transport.Conn).Data = s.Handler.OnNewSession(conn)
|
||||
log.Sugar.Debugf("%s连接 conn: %s", s.SourceType.String(), conn.RemoteAddr().String())
|
||||
if s.Handler != nil {
|
||||
conn.(*transport.Conn).Data = s.Handler.OnNewSession(conn)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -35,7 +37,7 @@ func (s *StreamServer[T]) OnDisConnected(conn net.Conn, err error) {
|
||||
log.Sugar.Debugf("%s断开连接 conn:%s", s.SourceType.String(), conn.RemoteAddr().String())
|
||||
|
||||
t := conn.(*transport.Conn)
|
||||
if t.Data != nil {
|
||||
if s.Handler != nil && t.Data != nil {
|
||||
s.Handler.OnCloseSession(t.Data.(T))
|
||||
t.Data = nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user