Exemplo n.º 1
0
        void ICommunicationService.UploadContent(UploadStreamMessage content)
        {
            Stream source = content.DataStream;

            if (owner != null)
                owner.RouteData(content.Context, content.ContentType, source);
        }
Exemplo n.º 2
0
        void ICommunicationService.UploadContent(UploadStreamMessage content)
        {
            Stream source = content.DataStream;
            MemoryTributary ms = new MemoryTributary();

            const int bufferLen = 65536;
            byte[] buffer = new byte[bufferLen];
            int count = 0;
            while ((count = source.Read(buffer, 0, bufferLen)) > 0)
            {
                ms.Write(buffer, 0, count);
            }

            ms.Seek(0, SeekOrigin.Begin);
            try
            {
                if (owner != null)
                    owner.RouteData(content.Context, content.ContentType, ms);
            }
            catch
            {
            }
            //MessageBox.Show(content.ContentType + " " + content.Context + " " + ms.Length);
            ms.Close();
        }
Exemplo n.º 3
0
        public void UploadContent(UploadStreamMessage content)
        {
            EndpointAddress ep = new EndpointAddress(uri);
            NetNamedPipeBinding binding = new NetNamedPipeBinding();
            binding.MaxReceivedMessageSize = int.MaxValue;
            binding.SendTimeout = TimeSpan.MaxValue;
            binding.TransferMode = TransferMode.Streamed;
            binding.MaxBufferSize = int.MaxValue;
            ICommunicationService proxy = DuplexChannelFactory<ICommunicationService>.CreateChannel(cbInstance,binding,ep);
            //DuplexChannelFactory<ICommunicationService> prox = new DuplexChannelFactory<ICommunicationService>(typeof(ContractCallback)).CreateChannel(binding, ep);

            proxy.UploadContent(new UploadStreamMessage() { Context = content.Context, ContentType = content.ContentType, DataStream = content.DataStream });

            var callback = OperationContext.Current
                        .GetCallbackChannel<IContractCallback>();
            callback.OnUploadContent();
            //delegate(IContractCallback callback) { callback.OnUploadContent(); };
        }