/// <summary> /// 关闭链接:底层通知 /// </summary> private void HanldeCloseConnect() { if (m_channel != null) { m_channel.Destroy(); NetChannelPools.Despawn(m_channel); m_channel = null; } if (OnClose != null) { OnClose(conn_idx); OnClose = null; } }
public override void Destroy() { if (m_socket != null) {//socket只有外部调用时才主动关闭,否则底层会先自己关闭 m_socket.Close(); m_socket = null; } if (m_channel != null) { m_channel.Destroy(); NetChannelPools.Despawn(m_channel); m_channel = null; } base.Destroy(); }
/// <summary> /// 关闭链接:底层通知 /// </summary> private void HanldeCloseConnect(long conn_idx) { NetChannel channel; if (m_channels.TryGetValue(conn_idx, out channel)) { channel.Destroy(); NetChannelPools.Despawn(channel); } m_channels.Remove(conn_idx); if (OnClose != null) { OnClose(conn_idx); } }
public override void Close() { if (m_socket != null) { m_socket.Close(); m_socket = null; } //需要放m_socket.Close()后,socket关闭时,内部回调的关闭事件HanldeCloseConnect不能正常执行 foreach (var obj in m_channels) { obj.Value.Destroy(); NetChannelPools.Despawn(obj.Value); } m_channels.Clear(); base.Close(); }