protected Channel CreateChannel(string path, ChannelMode mode) { Channel channel = new Channel(); bindChannel(channel); channel.Connect(URL + "/" + path, mode); return channel; }
protected override void Data(Channel channel, ChannelDataEventArgs e) { Assert.IsTrue(Compare(payload, e.Payload)); if (++count == 1000) { channel.Close(); } }
internal static Connection create (Channel channel, Uri uri) { Connection connection = null; string connurl = null; connurl = uri.Scheme + "://" + uri.Host + ":" + uri.Port; if (_connections.ContainsKey(connurl)) { List<Connection> all = _connections[connurl]; foreach (Connection conn in all) { if (conn._channels.ContainsKey(uri.AbsolutePath) == false) { connection = conn; break; } } } if (connection == null) { connection = new Connection(connurl, uri); if (_connections.ContainsKey(connurl) == false) { _connections.Add(connurl, new List<Connection>()); } _connections[connurl].Add(connection); } connection.allocChannel(channel); return connection; }
public void TestWithMessage() { Timeout(5000); open = CreateChannel("test-token?TOKEN", ChannelMode.ReadWrite); Wait(); }
public void TestWithDeny() { Timeout(5000); deny = CreateChannel("open-deny", ChannelMode.ReadWrite); Wait(); }
protected override void Closed(Channel channel, ChannelCloseEventArgs e) { Assert.IsTrue(e.WasClean); Assert.IsFalse(e.WasDenied); if (channel == emitListener) { Done(); } }
public void Test() { Timeout(10000); emitListener = CreateChannel("", ChannelMode.Read); closingChannel = CreateChannel("emit-back-on-close", ChannelMode.Read); Wait(); }
public static void Main(string[] args) { channel = new Channel(); channel.Connect("http://public.hydna.net/", ChannelMode.ReadWrite); channel.Open += c_Open; channel.Data += c_Data; channel.Closed += c_Closed; while (channel != null) Thread.SpinWait(1); }
protected override void Closed(Channel channel, ChannelCloseEventArgs e) { if (channel == deny) { Assert.IsTrue(e.WasDenied); Assert.IsFalse(e.WasClean); Assert.AreEqual(e.Text, "DENIED"); } else { Assert.IsTrue(e.WasClean); Assert.IsFalse(e.WasDenied); } Done(); }
protected override void Open(Channel channel, ChannelEventArgs e) { Assert.AreEqual(channel, open); Assert.AreEqual(e.Text, "TOKEN"); channel.Close(); }
static void c_Closed(object sender, ChannelCloseEventArgs e) { Console.WriteLine("Channel is now closed, bye.."); channel = null; }
protected virtual void Closed(Channel channel, ChannelCloseEventArgs e){}
protected virtual void Signal(Channel channel, ChannelEventArgs e){}
protected override void Signal(Channel channel, ChannelEventArgs e) { Assert.AreEqual(e.Text, Message); channel.Close(); }
protected Channel CreateRandomChannel(ChannelMode mode, bool secure) { Channel channel = new Channel(); bindChannel(channel); channel.Connect((secure ? "https://" : "") + UniqueUrl(), mode); return channel; }
void bindChannel (Channel channel) { channel.Open += delegate(object sender, ChannelEventArgs e) { try { Open((Channel) sender, e); } catch (Exception ex) { error = ex; } }; channel.Signal += delegate(object sender, ChannelEventArgs e) { try { Signal((Channel) sender, e); } catch (Exception ex) { error = ex; } }; channel.Data += delegate(object sender, ChannelDataEventArgs e) { try { Data((Channel) sender, e); } catch (Exception ex) { error = ex; } }; channel.Closed += delegate(object sender, ChannelCloseEventArgs e) { try { Closed((Channel) sender, e); } catch (Exception ex) { error = ex; } }; }
protected override void Open(Channel channel, ChannelEventArgs e) { if (channel == closingChannel) { channel.Close(Message); } }
protected virtual void Data(Channel channel, ChannelDataEventArgs e){}
void deallocChannel(Channel channel, Frame frame, string reason) { if (channel.AbsolutePath == null) return; if (_channels.ContainsKey(channel.AbsolutePath)) _channels.Remove(channel.AbsolutePath); if (channel.Ptr != 0) _routes.Remove(channel.Ptr); _refcount--; if (_refcount == 0) { close(); } channel.handleClose(frame, reason); }
void allocChannel(Channel channel) { string path; path = channel.AbsolutePath == null ? "/" : channel.AbsolutePath; if (_channels.ContainsKey(path)) { throw new Exception("Channel already created"); } _channels.Add(path, channel); _refcount++; if (_handshaked) { byte[] pathbuff = Encoding.UTF8.GetBytes(channel.AbsolutePath); Frame frame = Frame.Resolve(pathbuff); _adapter.Send(frame); } else { _openQueue.Enqueue(channel); } }
protected override void Open(Channel channel, ChannelEventArgs e) { for (int i = 0; i < 1000; i++) { channel.Send(payload); } }
protected override void Open(Channel channel, ChannelEventArgs e) { channel.Emit("ping"); }
void deallocChannel(Channel channel) { deallocChannel(channel, null, null); }
protected override void Open(Channel channel, ChannelEventArgs e) { channel.Send(payload); }
protected override void Closed(Channel channel, ChannelCloseEventArgs e) { Assert.IsTrue(e.WasClean); Assert.IsFalse(e.WasDenied); Done(); }
protected virtual void Open(Channel channel, ChannelEventArgs e){}