Currently, I have created a simple Signalr hub that I click on posts from a Unity5 project. Given that the SignalR2 client does not work with Unity5, I use websocketsharp to intercept websocket frames. Messages are successfully transferred to the hub, but when I try to call the method on the client, I do not get the payload string, only the message identifier {"I": 0}
Looking through the SignalR documentation, it looks like this is being sent last, but I have no idea how I can hold it. I am sure that this is something simple, but for life I can not understand.
UPDATE
Upon request, I added the code for the project below ...
SignalRClient.cs
using System; using System.Collections.Generic; using System.IO; using System.Net; using Newtonsoft.Json; using WebSocketSharp; namespace Assets.Scripts { class SignalRClient { private WebSocket _ws; private string _connectionToken; private Dictionary<string, UnTypedActionContainer> _actionMap; private readonly string _socketUrl = "http://localhost/"; private readonly string _socket = "ws://localhost/"; public SignalRClient() { _actionMap = new Dictionary<string, UnTypedActionContainer>(); var webRequest = (HttpWebRequest)WebRequest.Create(_socketUrl + "/signalr/negotiate?connectionData=%5B%7B%22name%22%3A%22myHub%22%7D%5D&clientProtocol=1.3"); var response = (HttpWebResponse)webRequest.GetResponse(); using (var sr = new StreamReader(response.GetResponseStream())) { var payload = sr.ReadToEnd(); UnityEngine.Debug.Log(payload); _connectionToken = Uri.EscapeDataString(JsonConvert.DeserializeObject<NegotiateResponse>(payload).ConnectionToken);
Myhub.cs
using System; using System.Threading; using System.Threading.Tasks; using Microsoft.AspNet.SignalR; public class MyHub : Hub { public void Send(string name, string message) { var myConn = Context.ConnectionId; Clients.All.broadcastMessage("John", "Hello"); } }
source share