简体   繁体   English

使用WCF的Silverlight文件传输

[英]Silverlight file transfer using WCF

I have a question regarding the technology available rather than a solution to the problem I'm facing. 我有一个关于可用技术的问题,而不是我所面临问题的解决方案。

I have implemented a client in Silverlight and a server using WCF, using basicHttpBinding with some modifications. 我已经在Silverlight中实现了客户端,并在WCF中实现了服务器,并使用basicHttpBinding进行了一些修改。

The SL client can upload as many files as he wishes. SL客户端可以根据需要上传任意数量的文件。 The uploading process is done by dividing the file into chunks and send it async. 通过将文件分成多个块并异步发送来完成上传过程。

There were 2 issues I had to face: 我不得不面对两个问题:

  1. Server receives the files not by their sending order / fixed by creating a simple buffer. 服务器接收的文件不是按其发送顺序,而是通过创建一个简单的缓冲区来解决。
  2. The client receives a finished event only when the chunk is being sent rather than when its being processed / implemented another OperationContract for IsFinished . 客户端仅在发送块时才接收完成事件,而不是在处理/实现IsFinished另一个OperationContract时才接收完成事件。

My question is am I doing it right? 我的问题是我做对了吗? Is there a mechanism that does the buffering itself? 是否存在缓冲本身的机制? I don't mind sharing the code although its working OK. 尽管可以正常工作,但我不介意共享代码。

Thanks! 谢谢! Moshe 摩西

I'm not sure why you decided to send your files in chunks. 我不确定为什么您决定分块发送文件。 I'm guessing perhaps due to the size of files you're transferring?. 我猜可能是由于要传输的文件大小? One possible alternative approach to this would be using WCF streaming. 一种可能的替代方法是使用WCF流。 Take a look at the following for details on why to use streaming and how to set it up: 请参阅以下内容,详细了解为什么要使用流媒体以及如何设置流媒体:

http://msdn.microsoft.com/en-us/library/ms789010.aspx http://msdn.microsoft.com/en-us/library/ms789010.aspx

http://blogs.msdn.com/b/carlosfigueira/archive/2010/07/08/using-transfermode-streamedresponse-to-download-files-in-silverlight-4.aspx http://blogs.msdn.com/b/carlosfigueira/archive/2010/07/08/using-transfermode-streamedresponse-to-download-files-in-silverlight-4.aspx

First of all, thanks for replying. 首先,感谢您的答复。

The thing is, as i understand, Silverlight does not support streaming (learned it the hard way). 事实是,据我了解,Silverlight不支持流传输(很难学到)。 Regarding the chucks, the files that are being transferred are huge and must be chucked. 关于卡盘,正在传输的文件很大,必须将其卡住。

Thanks, 谢谢,

Moshe 摩西

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM