diff --git a/TVServerKodi/Changelog.txt b/TVServerKodi/Changelog.txt index 205593b..a60119e 100644 --- a/TVServerKodi/Changelog.txt +++ b/TVServerKodi/Changelog.txt @@ -2,6 +2,7 @@ - Added: GetRecordingInfo: Allow resolving the hostname in an RTSP url to an IP-address - Fixed: GetRecordingInfo should return the same fields as getrecordings - Extended debug logging for adding schedules +- Fixed: DataWriter could throw an unhandled exception during TVService shutdown 1.18.0.138: - Updated: reference assemblies for MediaPortal 2.1.2 TVServer 1.18.0 diff --git a/TVServerKodi/Commands/DataWriter.cs b/TVServerKodi/Commands/DataWriter.cs index 7a7e433..4f4084a 100644 --- a/TVServerKodi/Commands/DataWriter.cs +++ b/TVServerKodi/Commands/DataWriter.cs @@ -1,9 +1,7 @@ using System; using System.Collections.Generic; -using System.Text; using System.Net.Sockets; using System.IO; -using TVServerKodi; namespace TVServerKodi.Commands { @@ -97,21 +95,33 @@ public String makeItemSmart(params Object[] arguments) public String makeItem(params String[] arguments) { - ensureNoNull(arguments, ""); + try + { + ensureNoNull(arguments, ""); - // escape all the arguments - String[] escaped = Array.ConvertAll(arguments,argumentEncoder); + // escape all the arguments + String[] escaped = Array.ConvertAll(arguments, argumentEncoder); - // join them up - return string.Join(argumentSeparator, arguments); + // join them up + return string.Join(argumentSeparator, arguments); + } + catch + { + return ""; + } } // writes a command out, ensure that it is written out public void write(String line) { - writer.Write(line + commandSeparator); - Console.WriteLine("Socket write: " + line + commandSeparator); - writer.Flush(); + try + { + writer.Write(line + commandSeparator); + Console.WriteLine("Socket write: " + line + commandSeparator); + writer.Flush(); + } + catch + { } } public void write(String line, bool escapeMe) { @@ -124,19 +134,29 @@ public void write(String line, bool escapeMe) public void writeBytes(Byte[] bytes) { - binWriter.Write(bytes); - binWriter.Flush(); + try + { + binWriter.Write(bytes); + binWriter.Flush(); + } + catch + { } } public void writeList(List list) { - ensureNoNull(list, ""); + try + { + ensureNoNull(list, ""); - // escape every value - List escaped = list.ConvertAll(listEncoder); + // escape every value + List escaped = list.ConvertAll(listEncoder); - // send it as one line - write(String.Join(listSeparator , escaped.ToArray())); + // send it as one line + write(String.Join(listSeparator, escaped.ToArray())); + } + catch + { } }