private void OnRealChannel_ReceivedData(object sender, ChannelDataReceivedEventArgs e) { SendDataToProxy(e.Data); string response = _process.StandardOutput.ReadLine(); var match = Regex.Match(response, @"([0-1]{1});" + @"([0-9a-fA-F]{8});" + @"([0-9a-fA-F]{1});" + @"([0-9a-fA-F])+;" + @"([0-9a-fA-F]{4});"); if (!match.Success) { return; } ReceivedData result = new ReceivedData(); try { result.DLC = Convert.ToInt32(match.Groups[3].Value, 16); } catch { return; } match = Regex.Match(response, @"([0-1]{1});" + @"([0-9a-fA-F]{8});" + @"([0-9a-fA-F]{1});" + @"([0-9a-fA-F]{" + (result.DLC * 2) + "});" + @"([0-9a-fA-F]{4});"); if (!match.Success) { return; } try { result.IsExtId = Convert.ToInt32(match.Groups[1].Value, 16) == 0 ? false : true; result.CanId = Convert.ToInt32(match.Groups[2].Value, 16); result.Time = Convert.ToInt32(match.Groups[5].Value, 16) / 1000.0; result.Payload = new byte[result.DLC]; for (int i = 0; i < result.DLC; i++) { result.Payload[i] = Convert.ToByte(match.Groups[4].Value.Substring(i * 2, 2), 16); } } catch { return; } RaiseReceivedData(result); }
internal void SendDataHandler(object sender, ChannelDataReceivedEventArgs e) { var server = (RtmpConnect)sender; var server_clients = _routedClients.FindAll((t) => t.Item2 == server.ClientID); foreach (var i in server_clients) { IStreamConnect client; ClientSession client_state = null; if (e.type != i.Item3) { continue; } ClientSessions.TryGetValue(i.Item1, out client_state); switch (i.Item3) { case ChannelType.Audio: if (client_state == null) { continue; } client = client_state.Connect; client.SendAmf0Data(e.e); break; case ChannelType.Video: if (client_state == null) { continue; } client = client_state.Connect; client.SendAmf0Data(e.e); break; case ChannelType.Message: throw new NotImplementedException(); } } }
public static void Raise(this FastSmartWeakEvent <ChannelDataReceivedEventHandler> ev, object sender, ChannelDataReceivedEventArgs e) { var d = ev.GetRaiseDelegate(); if (d != null) { d(sender, e); } }