public static int FromXml(System.IO.Stream stream, ChannelDelegate callback) { System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(stream); int count = FromXml(reader, callback); reader.Close(); stream.Close(); return(count); }
public void CreateChannel(string channelName) { _channelDelegate = new ChannelDelegate(); _channelDelegate.AppendMessage += AppendMsg; _channelDelegate.ShowAlert += ShowAlert; var channel = AgoraRtm.RtmKit.CreateChannelWithId(channelName, _channelDelegate); if (channel == null) { return; } channel.JoinWithCompletion(JoinChannelBlock); }
public AudioPlayerEngine() { _soundSystem = new SoundSystem(); _soundSystem.Init(32, InitFlags.Normal, (IntPtr)null); _callback = ChannelEndCallback; _soundSystem.SetStreamBufferSize(64 * 1024, TimeUnit.RawBytes); EqualizerEngine = new EqualizerEngine(_soundSystem); CurrentTimeChanged = Observable.Interval(TimeSpan.FromMilliseconds(1000)) .Select(x => CurrentTime) .DistinctUntilChanged(x => x.TotalSeconds); PlaybackStateChanged = Observable.Interval(TimeSpan.FromMilliseconds(300)) .Select(x => PlaybackState) .DistinctUntilChanged(x => x); TotalTimeChanged = Observable.Interval(TimeSpan.FromMilliseconds(1000)) .Select(x => TotalTime) .DistinctUntilChanged(x => x.TotalSeconds); }
public AudioPlayerEngine() { _soundSystem = new SoundSystem(); _soundSystem.Init(32, InitFlags.Normal, (IntPtr) null); _callback = ChannelEndCallback; _soundSystem.SetStreamBufferSize(64 * 1024, TimeUnit.RawBytes); EqualizerEngine = new EqualizerEngine(_soundSystem); CurrentTimeChanged = Observable.Interval(TimeSpan.FromMilliseconds(1000)) .Select(x => CurrentTime) .DistinctUntilChanged(x => x.TotalSeconds); PlaybackStateChanged = Observable.Interval(TimeSpan.FromMilliseconds(300)) .Select(x => PlaybackState) .DistinctUntilChanged(x => x); TotalTimeChanged = Observable.Interval(TimeSpan.FromMilliseconds(1000)) .Select(x => TotalTime) .DistinctUntilChanged(x => x.TotalSeconds); }
public void SetCallback(ChannelDelegate callback) { Code returnCode = SetCallback(DangerousGetHandle(), callback); Errors.ThrowError(returnCode); }
override public void RegisterClose(ChannelDelegate @delegate) { onClose.Add(@delegate); }
override public void RegisterConnect(ChannelDelegate @delegate) { onAccept.Add(@delegate); }
abstract public void RegisterConnect(ChannelDelegate @delegate);
private static int FromXml(System.Xml.XmlTextReader reader, ChannelDelegate callback) { reader.MoveToContent(); reader.ReadStartElement("channellist"); int counter = 0; while (reader.Read()) { if (reader.LocalName != "channel") { continue; } if (!reader.HasAttributes) { Console.WriteLine("channel doesn't have attributes, skipping"); continue; } Channel c = new Channel(reader["bid"], reader["name"], reader["alias"], reader["description"]); c.LegacyId = reader["id"]; string distros = reader["distro_target"]; if (distros != null) { foreach (string d in distros.Split(new Char[] { ':' })) { c.AddDistroTarget(d); } } ChannelType type = ChannelType.Unknown; string type_str = reader["type"]; if (type_str != null) { switch (type_str) { case "helix": type = ChannelType.Helix; break; case "debian": type = ChannelType.Debian; break; case "aptrpm": type = ChannelType.Aptrpm; break; case "yum": type = ChannelType.Yum; break; default: break; } } c.SetType(type); int subd_priority = 0; int unsubd_priority = 0; string priority = reader["priority"]; if (priority != null) { subd_priority = Channel.PriorityParse(priority); } priority = reader["priority_when_unsubscribed"]; if (priority != null) { unsubd_priority = Channel.PriorityParse(priority); } c.SetPriorities(subd_priority, unsubd_priority); c.Path = reader["path"]; c.FilePath = reader["file_path"]; c.IconFile = reader["icon"]; c.PkginfoFile = reader["pkginfo_file"]; string compressed = reader["pkginfo_compressed"]; if (compressed != null && compressed == "1") { c.PkginfoFileCompressed = true; } counter++; if (!callback(c)) { break; } } return(counter); }
void processMessage(MSP_Op code, byte[] bytes, byte length) { //Debug.WriteLine("message received: " + code.ToString()); switch (code) { case MSP_Op.Status: { ushort pidDeltaUs = BitConverter.ToUInt16(bytes, 0); ushort i2cError = BitConverter.ToUInt16(bytes, 2); ushort activeSensors = BitConverter.ToUInt16(bytes, 4); ushort mode = BitConverter.ToUInt16(bytes, 6); ushort profile = BitConverter.ToUInt16(bytes, 10); ushort cpuload = BitConverter.ToUInt16(bytes, 11); ushort gyroDeltaUs = BitConverter.ToUInt16(bytes, 13); if ((mode & 0x1) == 1) { if (arm != kChannelArmValue) { Debug.WriteLine("Ack! integrity error"); } } } break; case MSP_Op.Identify: { Debug.WriteLine("Received Identity if you care"); } break; case MSP_Op.FlightControllerVariant: { StringBuilder builder = new StringBuilder(); ASCIIEncoding ai = new ASCIIEncoding(); for (int i = 0; i < 4; i++) { builder.Append(ai.GetString(bytes, i, 1)); } Debug.WriteLine($"Flight Controller ID :{builder.ToString()}"); } break; case MSP_Op.RawIMU: { imu.accelerometer.X = BitConverter.ToInt16(bytes, 0) / 512.0f; imu.accelerometer.Y = BitConverter.ToInt16(bytes, 2) / 512.0f; imu.accelerometer.Z = BitConverter.ToInt16(bytes, 4) / 512.0f; imu.gyroscope.X = BitConverter.ToInt16(bytes, 6) * 4.0f / 16.4f; imu.gyroscope.Y = BitConverter.ToInt16(bytes, 8) * 4.0f / 16.4f; imu.gyroscope.Z = BitConverter.ToInt16(bytes, 10) * 4.0f / 16.4f; imu.magnetometer.X = BitConverter.ToInt16(bytes, 12) / 1090; imu.magnetometer.Y = BitConverter.ToInt16(bytes, 14) / 1090; imu.magnetometer.Z = BitConverter.ToInt16(bytes, 16) / 1090; } break; case MSP_Op.RC: { // Should only happen at startup... int activeChannels = length / 2; if (activeChannels > 0) { roll = BitConverter.ToUInt16(bytes, 0); } if (activeChannels > 1) { pitch = BitConverter.ToUInt16(bytes, 2); } if (activeChannels > 2) { yaw = BitConverter.ToUInt16(bytes, 4); } if (activeChannels > 3) { throttle = BitConverter.ToUInt16(bytes, 6); } if (activeChannels > 4) { aux1 = BitConverter.ToUInt16(bytes, 8); } if (activeChannels > 5) { aux2 = BitConverter.ToUInt16(bytes, 10); } if (activeChannels > 6) { arm = BitConverter.ToUInt16(bytes, 12); } if (activeChannels > 7) { aux4 = BitConverter.ToUInt16(bytes, 14); } ChannelDelegate?.Invoke(); } break; } }
private static extern Code SetCallback(IntPtr channel, ChannelDelegate callback);
public static int FromXml (System.IO.Stream stream, ChannelDelegate callback) { System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader (stream); int count = FromXml (reader, callback); reader.Close (); stream.Close (); return count; }
private static int FromXml (System.Xml.XmlTextReader reader, ChannelDelegate callback) { reader.MoveToContent (); reader.ReadStartElement ("channellist"); int counter = 0; while (reader.Read ()) { if (reader.LocalName != "channel") continue; if (!reader.HasAttributes) { Console.WriteLine ("channel doesn't have attributes, skipping"); continue; } Channel c = new Channel (reader["bid"], reader["name"], reader["alias"], reader["description"]); c.LegacyId = reader["id"]; string distros = reader["distro_target"]; if (distros != null) { foreach (string d in distros.Split (new Char[] {':'})) c.AddDistroTarget (d); } ChannelType type = ChannelType.Unknown; string type_str = reader["type"]; if (type_str != null) { switch (type_str) { case "helix": type = ChannelType.Helix; break; case "debian": type = ChannelType.Debian; break; case "aptrpm": type = ChannelType.Aptrpm; break; case "yum": type = ChannelType.Yum; break; default: break; } } c.SetType (type); int subd_priority = 0; int unsubd_priority = 0; string priority = reader["priority"]; if (priority != null) subd_priority = Channel.PriorityParse (priority); priority = reader["priority_when_unsubscribed"]; if (priority != null) unsubd_priority = Channel.PriorityParse (priority); c.SetPriorities (subd_priority, unsubd_priority); c.Path = reader["path"]; c.FilePath = reader["file_path"]; c.IconFile = reader["icon"]; c.PkginfoFile = reader["pkginfo_file"]; string compressed = reader["pkginfo_compressed"]; if (compressed != null && compressed == "1") c.PkginfoFileCompressed = true; counter++; if (!callback (c)) break; } return counter; }
public void RegisterClose(ChannelDelegate @delegate) { onClose = @delegate; }
abstract public void RegisterClose(ChannelDelegate @delegate);