UCMA Send File & File Transfer Sample
Asked Answered
K

0

8

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:[email protected] 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?

Koopman answered 28/8, 2015 at 8:56 Comment(4)
It looks like the invitation isn't being accepted, can you confirm that you are hitting the callback for Flow.BeginSendInstantMessage()?Smitt
I accepted the invitation but receive this error.Airbrush
@kdrlzmlr I'm also trying to send a file with UCMA. Did you manage to solve this?Packard
@meir Yes I did. Follow the instructions at this site. ocsgcf.blogspot.co.ukAirbrush

© 2022 - 2024 — McMap. All rights reserved.