Esempio n. 1
0
 protected Channel CreateChannel(string path, ChannelMode mode)
 {
     Channel channel = new Channel();
     bindChannel(channel);
     channel.Connect(URL + "/" + path, mode);
     return channel;
 }
Esempio n. 2
0
        protected override void Data(Channel channel, ChannelDataEventArgs e)
        {
			Assert.IsTrue(Compare(payload, e.Payload));
            if (++count == 1000) {
                channel.Close();
            }
        }
Esempio n. 3
0
        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;
        }
Esempio n. 4
0
        public void TestWithMessage()
        {
            Timeout(5000);

            open = CreateChannel("test-token?TOKEN", ChannelMode.ReadWrite);

            Wait();
        }
Esempio n. 5
0
        public void TestWithDeny()
        {
            Timeout(5000);

            deny = CreateChannel("open-deny", ChannelMode.ReadWrite);

            Wait();
        }
Esempio n. 6
0
 protected override void Closed(Channel channel, ChannelCloseEventArgs e)
 {
     Assert.IsTrue(e.WasClean);
     Assert.IsFalse(e.WasDenied);
     
     if (channel == emitListener) {
         Done();
     }
 }
Esempio n. 7
0
        public void Test()
        {
            Timeout(10000);

            emitListener = CreateChannel("", ChannelMode.Read);

            closingChannel = CreateChannel("emit-back-on-close",
                                           ChannelMode.Read);

            Wait();
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
     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();
     }
Esempio n. 10
0
        protected override void Open(Channel channel, ChannelEventArgs e)
        {
            Assert.AreEqual(channel, open);
			Assert.AreEqual(e.Text, "TOKEN");
            channel.Close();
        }
Esempio n. 11
0
 static void c_Closed(object sender, ChannelCloseEventArgs e)
 {
     Console.WriteLine("Channel is now closed, bye..");
     channel = null;
 }
Esempio n. 12
0
 protected virtual void Closed(Channel channel, ChannelCloseEventArgs e){}
Esempio n. 13
0
 protected virtual void Signal(Channel channel, ChannelEventArgs e){}
Esempio n. 14
0
        protected override void Signal(Channel channel, ChannelEventArgs e)
        {
			Assert.AreEqual(e.Text, Message);
            channel.Close();
        }
Esempio n. 15
0
 protected Channel CreateRandomChannel(ChannelMode mode, bool secure)
 {
     Channel channel = new Channel();
     bindChannel(channel);
     channel.Connect((secure ? "https://" : "") + UniqueUrl(), mode);
     return channel;
 }
Esempio n. 16
0
        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;
                }
            };
        }
Esempio n. 17
0
 protected override void Open(Channel channel, ChannelEventArgs e)
 {
     if (channel == closingChannel) {
         channel.Close(Message);
     }
 }
Esempio n. 18
0
 protected virtual void Data(Channel channel, ChannelDataEventArgs e){}
Esempio n. 19
0
        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);
        }
Esempio n. 20
0
        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);
            }
        }
Esempio n. 21
0
 protected override void Open(Channel channel, ChannelEventArgs e)
 {
     for (int i = 0; i < 1000; i++) {
         channel.Send(payload);
     }
 }
Esempio n. 22
0
 protected override void Open(Channel channel, ChannelEventArgs e)
 {
     channel.Emit("ping");
 }
Esempio n. 23
0
 void deallocChannel(Channel channel)
 {
     deallocChannel(channel, null, null);
 }
Esempio n. 24
0
 protected override void Open(Channel channel, ChannelEventArgs e)
 {
     channel.Send(payload);
 }
Esempio n. 25
0
 protected override void Closed(Channel channel, ChannelCloseEventArgs e)
 {
     Assert.IsTrue(e.WasClean);
     Assert.IsFalse(e.WasDenied);
     Done();
 }
Esempio n. 26
0
 protected virtual void Open(Channel channel, ChannelEventArgs e){}