Beispiel #1
0
        private static void ReconnectAllSockets()
        {
            foreach (KeyValuePair <string, TcpClientEntry> kvPair in DllEntry.tcpClients)
            {
                string         hash  = kvPair.Key;
                TcpClientEntry entry = kvPair.Value;

                if (!DllEntry.IsConnected(entry.TcpClient))
                {
                    try
                    {
                        entry.TcpClient.Close();
                    }
                    catch (ObjectDisposedException) { }

                    try
                    {
                        entry.TcpClient = DllEntry.Connect(entry.Uri);
                        Log("Reconnected");
                    }
                    catch (SocketException e)
                    {
                        Log($"Reconnect - Socket exception {e.Message}");
                    }
                }
            }
        }
Beispiel #2
0
        public static string IsConnected(string hash)
        {
            if (!DllEntry.tcpClients.ContainsKey(hash))
            {
                return("error");
            }

            return(DllEntry.IsConnected(DllEntry.tcpClients[hash].TcpClient) ? "success" : "false");
        }