void GlowReader_FramingError(object sender, EmberLib.Framing.FramingReader.FramingErrorArgs e) { Console.WriteLine("GlowReader framing error: {0}", e.Message); }
public GlowRootReadyArgs(EmberLib.Glow.GlowContainer root) { Root = root; }
void GlowReader_Error(object sender, EmberLib.Glow.Framing.GlowReader.ErrorArgs e) { if(e.ErrorCode != _lastGlowFramingError) { OnNotification(new NotificationArgs(String.Format("Framing Error: {0}", e.Message))); _lastGlowFramingError = e.ErrorCode; } }
void GlowReader_RootReady(object sender, EmberLib.AsyncDomReader.RootReadyArgs e) { var root = e.Root as EmberLib.Glow.GlowContainer; State = GlowEndPointState.Connected; if(root != null) OnGlowRootReady(new GlowRootReadyArgs(root)); else OnNotification(new NotificationArgs(String.Format("Unexpected Ember Root: {0} ({1})", e.Root, e.Root.GetType()))); }
/// <summary> /// Sends an ember/glow tree to the remote host. /// </summary> /// <param name="root">The root of the tree to send.</param> public void Write(EmberLib.Glow.GlowContainer root) { lock(_sync) { var tcpClient = _tcpClient; if(tcpClient != null && tcpClient.Connected) { var output = CreateFramingOutput( (_, e) => { var stream = tcpClient.GetStream(); stream.Write(e.FramedPackage, 0, e.FramedPackageLength); }); using(output) { root.Encode(output); output.Finish(); } } } }