Skip to content

Commit

Permalink
Fixed: DataWriter could throw an unhandled exception during TVService…
Browse files Browse the repository at this point in the history
… shutdown
  • Loading branch information
margro committed Dec 15, 2018
1 parent 49092cd commit cbd9d7e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 17 deletions.
1 change: 1 addition & 0 deletions TVServerKodi/Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
54 changes: 37 additions & 17 deletions TVServerKodi/Commands/DataWriter.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -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<string,string>(arguments,argumentEncoder);
// escape all the arguments
String[] escaped = Array.ConvertAll<string, string>(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)
{
Expand All @@ -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<string> list)
{
ensureNoNull(list, "");
try
{
ensureNoNull(list, "");

// escape every value
List<string> escaped = list.ConvertAll<string>(listEncoder);
// escape every value
List<string> escaped = list.ConvertAll<string>(listEncoder);

// send it as one line
write(String.Join(listSeparator , escaped.ToArray()));
// send it as one line
write(String.Join(listSeparator, escaped.ToArray()));
}
catch
{ }
}


Expand Down

0 comments on commit cbd9d7e

Please sign in to comment.