private void _socketOnData(ReactivixNetworkSocket client, string data) { if (data == "") { return; } string[] separator = new string[] { "}{" }; List <string> queue = new List <string>(data.Replace("}{", "}}{{").Split(separator, StringSplitOptions.None)); foreach (string raw in queue) { QuarkNetworkPacket packet = JsonConvert.DeserializeObject <QuarkNetworkPacket>(raw.Trim()); if (packet == null) { continue; } if (packet.Response != "") { _trigger(_responses, packet, packet.Response); } if (packet.Event != "") { _trigger(_events, packet, packet.Event); } } }
public QuarkNetworkClient(IReactivixNetworkTransport transport, string host, int port) { _responses = new List <Callback>(); _events = new List <Callback>(); Socket = new ReactivixNetworkSocket(transport, host, port); Socket.OnConnect += _socketOnConnect; Socket.OnData += _socketOnData; Socket.OnClose += _socketOnClose; Socket.OnError += _socketOnError; }
private void _socketOnClose(ReactivixNetworkSocket client) { OnClose(this); }
private void _socketOnConnect(ReactivixNetworkSocket client) { OnConnect(this); }
private void _socketOnError(ReactivixNetworkSocket client, Exception e) { OnError(this, e); }