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); } } }
private void _trigger(List <Callback> callbacks, QuarkNetworkPacket packet, string url) { foreach (Callback callback in callbacks) { if (callback.URL != url) { continue; } packet.TypeData = callback.TypeData; callback.Worker(this, packet); } }