断开时关闭连接
This commit is contained in:
parent
750992cfe4
commit
174a01f864
|
@ -64,6 +64,7 @@ func (slf *event) OnConnectionClosedEvent(conn *Conn) {
|
|||
for _, handle := range slf.connectionClosedEventHandles {
|
||||
handle(slf.Server, conn)
|
||||
}
|
||||
conn.Close()
|
||||
}
|
||||
|
||||
// RegConnectionOpenedEvent 在连接打开后将立刻执行被注册的事件处理函数
|
||||
|
|
|
@ -165,7 +165,6 @@ func (slf *Server) Run(addr string) error {
|
|||
go func(conn *Conn) {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
conn.Close()
|
||||
slf.OnConnectionClosedEvent(conn)
|
||||
}
|
||||
}()
|
||||
|
@ -242,7 +241,6 @@ func (slf *Server) Run(addr string) error {
|
|||
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
conn.Close()
|
||||
slf.OnConnectionClosedEvent(conn)
|
||||
}
|
||||
}()
|
||||
|
|
Loading…
Reference in New Issue