UCMA Send File & File Transfer Sample

☆樱花仙子☆ 提交于 2021-02-08 13:05:25

问题


There are no samples using for UCMA to send file from applicationendpoint to userendpoint or vice versa.

I've tried below sample but it didn't work. See code and error:

        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 said: Invitation-Command: CANCEL Invitation-Cookie: 33267 Cancel-Code: FAIL

Can anybody help or give any sample for sending file in UCMA for file transfer?

来源:https://stackoverflow.com/questions/32267114/ucma-send-file-file-transfer-sample

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!