/// <summary>
        /// An answer on a blind transfer means the remote end of the dialogue being replaced should be re-invited and then the replaced dialogue
        /// should be hungup.
        /// </summary>
        /// <param name="contentType"></param>
        /// <param name="body"></param>
        /// <param name="toTag"></param>
        /// <param name="answeredDialogue"></param>
        /// <param name="transferMode"></param>
        /// <returns></returns>
        public SIPDialogue Answer(string contentType, string body, string toTag, SIPDialogue answeredDialogue, SIPDialogueTransferModesEnum transferMode)
        {
            try
            {
                if (m_answered)
                {
                    Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "A blind transfer received an answer on an already answered call, hanging up dialogue.", m_owner));
                    answeredDialogue.Hangup(m_sipTransport, m_outboundProxy);
                }
                else
                {
                    m_answered = true;
                    Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "A blind transfer received an answer.", m_owner));

                    UASStateChanged?.Invoke(this, SIPResponseStatusCodesEnum.Ok, null);

                    BlindTransfer_External(m_dialogueToReplace, m_oppositeDialogue, answeredDialogue);
                }
                TransactionComplete.Invoke(this);
                return(null);
            }
            catch (Exception excp)
            {
                logger.Error("Exception SIPTransferServerUserAgent Answer. " + excp.Message);
                throw;
            }
        }
        /// <summary>
        /// An answer on a blind transfer means the remote end of the dialogue being replaced should be re-invited and then the replaced dialogue
        /// should be hungup.
        /// </summary>
        /// <param name="contentType"></param>
        /// <param name="body"></param>
        /// <param name="toTag"></param>
        /// <param name="answeredDialogue"></param>
        /// <param name="transferMode"></param>
        /// <returns></returns>
        public SIPDialogue Answer(string contentType, string body, string toTag, SIPDialogue answeredDialogue,
                                  SIPDialogueTransferModesEnum transferMode)
        {
            try
            {
                if (m_answered)
                {
                    answeredDialogue.Hangup(m_sipTransport, m_outboundProxy);
                }
                else
                {
                    m_answered = true;

                    UASStateChanged?.Invoke(this, SIPResponseStatusCodesEnum.Ok, null);

                    BlindTransfer_External(m_dialogueToReplace, m_oppositeDialogue, answeredDialogue);
                }

                TransactionComplete.Invoke(this);
                return(null);
            }
            catch (Exception excp)
            {
                logger.Error("Exception SIPTransferServerUserAgent Answer. " + excp.Message);
                throw;
            }
        }
        internal void AddFrame(int frameIndex, byte[] payload)
        {
            lock (syncObj)
            {
                if (!transactionInProgress)
                {
                    tempFrameData.Add(frameIndex, payload);
                    return;
                }

                Debug.WriteLine(String.Format("Received frame {0} of {1}: Payload={2}",
                                              frameIndex + 1, expectedFrames, payload.ToByteString()));


                frameData.Add(frameIndex, payload);
                SetBitmap(frameIndex);
                if (frameData.Count % 4 == 0 || expectedFrames == frameData.Count)
                {
                    var bitmapClone = (byte[])bitmap.Clone();
                    Debug.Write(String.Format("Raising SendControlFrame with data {0}", bitmapClone.ToByteString()));
                    SendControlFrame?.Invoke(this, bitmapClone);
                }

                if (frameData.Count != expectedFrames)
                {
                    return;
                }

                // Build messsage
                byte[] data = new byte[payload.Length * expectedFrames];
                for (int i = 0; i < expectedFrames; i++)
                {
                    Array.Copy(frameData[i], 0, data, i * payload.Length, payload.Length);
                }

                Debug.WriteLine("receive complete");
                transactionInProgress = false;
                tempFrameData.Clear();
                TransactionComplete?.Invoke(this, data);
            }
        }
        public FrameService()
        {
            this.frameFactory       = new FrameFactory();
            this.frameValidator     = new FrameValidation();
            this.frameCollector     = new FrameCollector();
            this.InfoFrameReceived += (sender, arg) =>
            {
                infoFrameCount++;
            };

            this.frameCollector.SendControlFrame += (sender, data) =>
            {
                Debug.WriteLine("Send control frame: " + data.ToByteString());
                var controlFrameData = frameFactory.BuildControlFrame(data).Serialize();
                SendData?.Invoke(sender, controlFrameData);
            };
            this.frameCollector.TransactionComplete += (sender, data) =>
            {
                TransactionComplete.Invoke(sender, data);
            };
        }
예제 #5
0
 protected virtual void OnTransactionComplete()
 {
     TransactionComplete?.Invoke(this, EventArgs.Empty);
 }
 private void UASTransaction_TransactionRemoved(SIPTransaction sipTransaction)
 {
     TransactionComplete?.Invoke(this);
 }
 public SIPDialogue Answer(string contentType, string body, string toTag, SIPDialogue answeredDialogue, SIPDialogueTransferModesEnum transferMode)
 {
     TransactionComplete.Invoke(this);
     throw new NotImplementedException();
 }
 public void AnswerNonInvite(SIPResponseStatusCodesEnum answerStatus, string reasonPhrase,
                             string[] customHeaders, string contentType, string body)
 {
     TransactionComplete.Invoke(this);
     throw new NotImplementedException();
 }