public static MyMsrpSession TakeIncomingSession(MySipStack sipStack, MsrpSession session, SipMessage message) { MyMsrpSession msrpSession = null; MediaType mediaType; SdpMessage sdp = message.getSdpMessage(); String fromUri = message.getSipHeaderValue("f"); if (String.IsNullOrEmpty(fromUri)) { LOG.Error("Invalid fromUri"); return(null); } if (sdp == null) { LOG.Error("Invalid Sdp content"); return(null); } String fileSelector = sdp.getSdpHeaderAValue("message", "file-selector"); mediaType = String.IsNullOrEmpty(fileSelector) ? MediaType.Chat : MediaType.FileTransfer; if (mediaType == MediaType.Chat) { msrpSession = MyMsrpSession.CreateIncomingSession(sipStack, session, mediaType, fromUri); } else { String name = null; String type = null; String[] attributes = fileSelector.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); foreach (String attribute in attributes) { String[] avp = attribute.Split(":".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (avp.Length >= 2) { if (String.Equals(avp[0], "name", StringComparison.InvariantCultureIgnoreCase) && avp[1] != null) { name = avp[1].Replace("\"", String.Empty); } if (String.Equals(avp[0], "type", StringComparison.InvariantCultureIgnoreCase) && avp[1] != null) { type = avp[1]; } } } if (name == null) { LOG.Error("Invalid file name"); return(null); } msrpSession = MyMsrpSession.CreateIncomingSession(sipStack, session, mediaType, fromUri); msrpSession.filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), String.Format("{0}/{1}", MyMsrpSession.DESTINATION_FOLDER, name)); msrpSession.fileType = type; } return(msrpSession); }
internal MyMsrpCallback(MyMsrpSession session) : base() { this.session = session; #if WINRT mStart = Marshal.AllocHGlobal(sizeof(Int64)); mEnd = Marshal.AllocHGlobal(sizeof(Int64)); mTotal = Marshal.AllocHGlobal(sizeof(Int64)); #endif }
public static MyMsrpSession CreateOutgoingSession(MySipStack sipStack, MediaType mediaType, String remoteUri) { if (mediaType == MediaType.FileTransfer || mediaType == MediaType.Chat) { MyMsrpSession msrpSession = new MyMsrpSession(sipStack, null, mediaType, remoteUri); sSessions.Add(msrpSession.Id, msrpSession); return(msrpSession); } return(null); }
public static void ReleaseSession(MyMsrpSession session) { if (session != null) { lock (MyMsrpSession.sSessions) { long id = session.Id; session.Dispose(); sSessions.Remove(id); } } }
public static MyMsrpSession CreateOutgoingSession(MySipStack sipStack, MediaType mediaType, String remoteUri) { if (mediaType == MediaType.FileTransfer || mediaType == MediaType.Chat) { MyMsrpSession msrpSession = new MyMsrpSession(sipStack, null, mediaType, remoteUri); sSessions.Add(msrpSession.Id, msrpSession); return msrpSession; } return null; }
internal MyMsrpCallback(MyMsrpSession session) : base() { this.session = session; }