I am using a WinRT client. I receive this exception when I try to send a message.
Unexpected character encountered while parsing value: <.
The problem occurs when you send an object to the hub, and the object is not defined on the hub. The object is a Bindable object (ViewModel). I don’t want to include all the property notify change stuff on the web project.
Client Code
return Proxy.Invoke("PlayerUpdate", sessionData);
Try one was to have the hub accept an ‘object’ parameter
public async Task PlayerUpdate(string group, object sessionData)
{
await Clients[group].PlayerUpdate(sessionData);
}
Try two was to have the hub accept an (json) ‘string’ parameter
public async Task PlayerUpdate(string group, string sessionData)
{
await Clients[group].PlayerUpdate(sessionData);
}
Try three was to pre-serialize the object client side
var str = JsonConvert.SerializeObject(refresh);
return Proxy.Invoke("PlayerUpdate", str);
Nothing is working. Plan 4 is to define some data transfer objects in a shared libarary to send. I really dont want to do that as It will about double my code.
Solved.
My repo project was fine, so I concluded that something else was the matter.
After some experimentation I discovered the real problem was that I had incorrect parameters in my HUB method. Simply put, I was sending 2 parameters when my hub methods only accepted 1.
Thanks for the interest, sorry for the confusion. Perhaps a better exception message is in order?