UCMA发送文件&文件传输示例

时间:2015-08-28 08:56:35

标签: file api transfer lync ucma

没有样本用于UCMA将文件从applicationendpoint发送到userendpoint,反之亦然。

我试过以下样本,但它没有用。请参阅代码和错误:

        if (e.State == MediaFlowState.Active)
        {
            byte[] fileBytes = null;
            using (FileStream fs = File.OpenRead(_fileToSend))
            {
                fileBytes = new byte[fs.Length];
                fs.Read(fileBytes, 0, fileBytes.Length);
            }

            ContentType ct = new ContentType("text/x-msmsgsinvite");
            ct.CharSet = "UTF-8";
            StringBuilder sb = new StringBuilder();
            sb.Append("Application-Name: File Transfer\r\n");
            sb.Append("Application-GUID: {5D3E02AB-6190-11d3-BBBB-00C04F795683}\r\n");
            sb.Append("Invitation-Command: INVITE\r\n");
            sb.Append("Invitation-Cookie: 33267\r\n");
            sb.Append("Application-File: Readme.txt\r\n");
            sb.Append("Application-FileSize: " + fileBytes.Length.ToString() + "\r\n");
            sb.Append("Connectivity: N\r\n\r\n");
            string s = sb.ToString();
            byte[] bytes1 = Encoding.UTF8.GetBytes(s);

            try
            {
                _instantMessagingFlow.BeginSendInstantMessage(ct, bytes1, result1 =>
                {
                    _instantMessagingFlow.EndSendInstantMessage(result1);
                }, null);

                WriteLog.AddLine("File sent to: " + _coachSipAddress + " from: " + _userSipAddress + " the file: " + _fileToSend);
            }
            catch (Exception ex)
            {
                WriteLog.AddLine("File couldn't sent " + ex.StackTrace);
            }
        }
  

11:16 sip:emre@dev-adoptuc.com说:邀请 - 命令:取消   邀请 - Cookie:33267取消代码:FAIL

有人可以帮助或提供任何样本,以便在UCMA中发送文件进行文件传输吗?

0 个答案:

没有答案