Esempio n. 1
0
        public void TestData()
        {
            var usertoken  = new System.Collections.Concurrent.ConcurrentQueue <byte[]>();
            var protocol   = new Never.Sockets.AsyncArgs.Connection.DataProtocol();
            var helloworld = Encoding.UTF8.GetBytes("hello world");

            var split = helloworld.Split(2);
            var data  = protocol.To(helloworld);

            usertoken.Enqueue(data);

            var next = protocol.From(usertoken);
            var tip  = Encoding.UTF8.GetString(next);

            var l  = BitConverter.GetBytes(Encoding.UTF8.GetBytes("hello world").Length);
            var s1 = Encoding.UTF8.GetBytes("hello ");
            var s2 = Encoding.UTF8.GetBytes("world");

            usertoken.Enqueue(l);
            usertoken.Enqueue(s1);
            usertoken.Enqueue(s2);

            next = protocol.From(usertoken);
            tip  = Encoding.UTF8.GetString(next);

            usertoken.Enqueue(l);
            usertoken.Enqueue(s2);

            next = protocol.From(usertoken);

            usertoken.Enqueue(s1);
            next = protocol.From(usertoken);
            tip  = Encoding.UTF8.GetString(next);
        }
Esempio n. 2
0
        public void TestEmpty()
        {
            var value = string.Empty;
            var len   = BitConverter.GetBytes(value.Length);
            var data  = Encoding.UTF8.GetBytes(value);

            var s         = ObjectExtension.Combine(len, data);
            var usertoken = new System.Collections.Concurrent.ConcurrentQueue <byte[]>();
            var protocol  = new Never.Sockets.AsyncArgs.Connection.DataProtocol();

            usertoken.Enqueue(s);
            usertoken.Enqueue(Encoding.UTF8.GetBytes("hello world"));
            var next = protocol.From(usertoken);
            var tip  = Encoding.UTF8.GetString(next);
        }