Beispiel #1
0
        private static async Task <bool> IsServerTheAwake()
        {
            ResourceLoader config  = ResourceLoader.GetForViewIndependentUse("Config");
            bool           isAwake = false;
            StreamSocket   socket  = new StreamSocket();

            Windows.Networking.HostName serverHost = new Windows.Networking.HostName(config.GetString("NetworkHelper_HostName"));
            string serverPort = config.GetString("NetworkHelper_Port");

            try
            {
                await socket.ConnectAsync(serverHost, serverPort);

                isAwake = true;
                await socket.CancelIOAsync();
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                await _log.InfoAsync("Der Server ist nicht eingeschaltet", ex);
            }
            catch (Exception ex)
            {
                await _log.ErrorAsync("Die Überprüfung, ob der Server eingeschaltet ist, ist fehlgeschlagen.", ex);
            }
            finally
            {
                socket.Dispose();
            }
            return(isAwake);
        }
Beispiel #2
0
        private async Task SendMessage(string msg)
        {
            await _log.DebugAsync($"Aria2: Write Message: {msg}");

            _messageWriter.WriteString(msg);
            try
            {
                await _messageWriter.StoreAsync();

                await _messageWriter.FlushAsync();

                await _log.DebugAsync($"Aria2: Message send: {msg}");
            }
            catch (Exception ex)
            {
                await _log.ErrorAsync("Fehler beim Speichern des Json-Objects", ex);
            }
        }