Ejemplo n.º 1
0
        private void DispatchBlock(StreamBlock block)
        {
            TRACE("DISPATCH BLOCK");
            if (block == null)
            {
                block = outgoing_stream.Peek();
                if (block == null)
                {
                    return;
                }
            }
            switch (block.ContentType)
            {
            case StreamBlock.ContentTypes.StreamData:
                os_socket.BeginSend(block.Data, 0, block.TotalBytes, SocketFlags.None,
                                    SendAsyncResult, block);
                break;

            /*case StreamBlock.ContentTypes.OOBData:
             * os_socket.BeginSend(block.Data, 0, block.TotalBytes, SocketFlags.OutOfBand,
             *                  new AsyncCallback(SendAsyncResult), os_socket);
             * break;*/
            case StreamBlock.ContentTypes.Disconnect:
                try
                {
                    os_socket.Shutdown(SocketShutdown.Send);
                    os_socket.Close();
                }
                catch (ObjectDisposedException)
                {
                }
                break;
            }
        }
Ejemplo n.º 2
0
 public virtual void EnqueueBlock(StreamBlock block)
 {
     TRACE("ENQUEUE BLOCK [{0}]", block.ContentType);
     if (outgoing_stream.Enqueue(block))
     {
         DispatchBlock(block);
     }
 }
Ejemplo n.º 3
0
        public void StartReceiver()
        {
            TRACE("START RECEIVER");
            var block = new StreamBlock
            {
                ContentType = StreamBlock.ContentTypes.StreamData,
                Data        = new byte[MaxBlockSize],
                TotalBytes  = MaxBlockSize
            };

            os_socket.BeginReceive(block.Data, 0, block.TotalBytes, 0, ReadAsyncResult, block);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// callback, este metodo es llamado cuando se reciben datos por el socket.
 /// </summary>
 public abstract void OnReceive(StreamBlock block);
Ejemplo n.º 5
0
 public override void OnReceive(StreamBlock block)
 {
     TRACE("CLIENT ON RECEIVE");
     Source.EnqueueBlock(block);
 }
Ejemplo n.º 6
0
 public override void OnReceive(StreamBlock block)
 {
     TRACE("SERVER ON RECEIVE");
     Target.EnqueueBlock(block);
 }