2010-04-13, 12:22
Well the framework that works with other JSONRPC server original code is :
To make it work with XBMC JSONRPC server i need to change this to :
Perhaps it's a bom problem or i don't know but if i just change the UTF8 to ASCII is works and it don't when i revert back with the errors seen in the log file.
Code:
public virtual object Invoke(Type returnType, string method, object args)
{
if (method == null)
throw new ArgumentNullException("method");
if (method.Length == 0)
throw new ArgumentException(null, "method");
if (returnType == null)
throw new ArgumentNullException("returnType");
var request = GetWebRequest(new Uri(Url));
request.Method = "POST";
using (var stream = request.GetRequestStream())
using (var writer = new StreamWriter(stream, Encoding.[b][size=large]UTF8[/size][/b]))
{
var call = new JsonObject();
call["id"] = ++_id;
call["jsonrpc"] = "2.0";
call["method"] = method;
if (args != null)
call["params"] = args;
JsonConvert.Export(call, writer);
}
using (var response = GetWebResponse(request))
using (var stream = response.GetResponseStream())
using (var reader = new StreamReader(stream, Encoding.UTF8))
return OnResponse(JsonText.CreateReader(reader), returnType);
}
To make it work with XBMC JSONRPC server i need to change this to :
Code:
public virtual object Invoke(Type returnType, string method, object args)
{
if (method == null)
throw new ArgumentNullException("method");
if (method.Length == 0)
throw new ArgumentException(null, "method");
if (returnType == null)
throw new ArgumentNullException("returnType");
var request = GetWebRequest(new Uri(Url));
request.Method = "POST";
using (var stream = request.GetRequestStream())
using (var writer = new StreamWriter(stream, Encoding.[b][size=large]ASCII[/size][/b]))
{
var call = new JsonObject();
call["id"] = ++_id;
call["jsonrpc"] = "2.0";
call["method"] = method;
if (args != null)
call["params"] = args;
JsonConvert.Export(call, writer);
}
using (var response = GetWebResponse(request))
using (var stream = response.GetResponseStream())
using (var reader = new StreamReader(stream, Encoding.UTF8))
return OnResponse(JsonText.CreateReader(reader), returnType);
}
Perhaps it's a bom problem or i don't know but if i just change the UTF8 to ASCII is works and it don't when i revert back with the errors seen in the log file.