示例#1
0
 /// <summary>
 /// Al desconectarse toda la red mesh
 /// </summary>
 /// <param name="sender">Emisor</param>
 /// <param name="e">Evento</param>
 private void MeshServer_OnMeshKilled(object sender, EventArgs e)
 {
     foreach (IChannel channel in m_channels.Values)
     {
         OnChannelDisconnected?.Invoke(this, channel);
         channel.Dispose();
     }
     m_channels = new Dictionary <string, IChannel>();
     Debug.WriteLine(this, "Canales purgados", VerbosityLevel.Debug);
 }
        /// <summary>
        /// Eliminar canal
        /// </summary>
        /// <param name="channel">Canal a eliminar</param>
        public void RemoveChannel(IChannel channel)
        {
            if (!m_channels.Contains(channel))
            {
                return;
            }

            m_channels.Remove(channel);
            OnChannelDisconnected?.Invoke(this, channel);
            Debug.WriteLine(this, "Canal en memoria eliminado: " + channel.GetType().FullName, VerbosityLevel.Debug);
        }
        /// <summary>
        /// Al cerrarse una conexión Socket
        /// </summary>
        /// <param name="sender">Emisor</param>
        /// <param name="e">Datos de conexión</param>
        private void SocketServer_OnSocketClose(object sender, SocketConnection e)
        {
            if (!m_channels.ContainsKey(e.ConnectionId))
            {
                Debug.WriteLine(this, $"Se recibio un mensaje de desconexión para el Socket {e.ConnectionId} pero el canal no existia", VerbosityLevel.Debug);
                return;
            }

            IChannel channel = m_channels[e.ConnectionId];

            OnChannelDisconnected?.Invoke(this, channel);
            Debug.WriteLine(this, "Se desconecto un canal Socket");
        }
示例#4
0
        /// <summary>
        /// Eliminar canal
        /// </summary>
        /// <param name="ipPort">IP / Puerto</param>
        private void RemoveChannel(string ipPort)
        {
            if (!m_channels.ContainsKey(ipPort))
            {
                Debug.WriteLine(this, "No se pudo eliminar un canal TCP Socket ya que el IP / Puerto no están registrado", VerbosityLevel.Warning);
                return;
            }

            IChannel channel = m_channels[ipPort];

            m_channels.Remove(ipPort);
            OnChannelDisconnected?.Invoke(this, channel);
            Debug.WriteLine(this, "Se elimino un canal TCP Socket correctamente", VerbosityLevel.Debug);
        }
示例#5
0
 /// <summary>
 /// Eliminar canal de comunicación mesh
 /// </summary>
 /// <param name="mac">Dirección MAC del canal</param>
 private void DeleteChannel(string mac)
 {
     if (m_channels.ContainsKey(mac))
     {
         IChannel channel = m_channels[mac];
         channel.Dispose();
         m_channels.Remove(mac);
         OnChannelDisconnected?.Invoke(this, channel);
         Debug.WriteLine(this, "Canal de comunicación eliminado: " + mac, VerbosityLevel.Info);
     }
     else
     {
         Debug.WriteLine(this, "El canal requerido a eliminar no existe: " + mac, VerbosityLevel.Warning);
     }
 }