示例#1
0
		public static IProxie Create(int transactionId, Trunk trunk, ByteArrayPart toTag)
		{
			int tag;
			Dialog dialog1 = null;
			if (HexEncoding.TryParseHex8(toTag, out tag))
				dialog1 = trunk.GetDialog1(tag);

			return (dialog1 == null) ? null : new TrunkDialogProxie(transactionId, trunk, tag, dialog1);
		}
示例#2
0
        public static IProxie Create(int transactionId, Trunk trunk, ByteArrayPart toTag)
        {
            int    tag;
            Dialog dialog1 = null;

            if (HexEncoding.TryParseHex8(toTag, out tag))
            {
                dialog1 = trunk.GetDialog1(tag);
            }

            return((dialog1 == null) ? null : new TrunkDialogProxie(transactionId, trunk, tag, dialog1));
        }
示例#3
0
        public void GenerateForwardedRequest(SipMessageWriter writer, SipMessageReader reader, ArraySegment <byte> content, ConnectionAddresses fromConnectionAddress, int serverTransactionId)
        {
            //dialog2 = new Dialog(reader, fromTag, fromConnectionAddress);

            Dialog dialog1 = null;

            if (HexEncoding.TryParseHex8(reader.To.Tag, out tag))
            {
                dialog1 = trunk.GetDialog1(tag);
            }
            else
            {
                tag = DialogManager.NewLocalTag();
            }

            dialog2 = new Dialog(reader, tag, fromConnectionAddress);
            trunk.AddDialog2(tag, dialog2);

            /////////////////////////////////////////////////////////////////////////////////

            writer.WriteRequestLine(reader.Method, binding.AddrSpec);

            //var msReceivedCid = fromConnectionAddress.ToLowerHexChars(serverTransactionId);
            //writer.WriteVia(binding.ConnectionAddresses.Transport, binding.ConnectionAddresses.LocalEndPoint, TransactionId, msReceivedCid);
            writer.WriteVia(binding.ConnectionAddresses.Transport, binding.ConnectionAddresses.LocalEndPoint, TransactionId);

            for (int i = 0; i < reader.Count.HeaderCount; i++)
            {
                switch (reader.Headers[i].HeaderName)
                {
                case HeaderNames.MaxForwards:
                    writer.WriteMaxForwards((reader.MaxForwards == int.MinValue) ? 69 : reader.MaxForwards - 1);
                    break;

                case HeaderNames.Contact:
                    writer.WriteContact(binding.ConnectionAddresses.LocalEndPoint, binding.ConnectionAddresses.Transport);
                    break;

                case HeaderNames.To:
                    writer.WriteTo(trunk.ForwardCallToUri, (dialog1 != null) ? dialog1.RemoteTag : ByteArrayPart.Invalid);
                    break;

                case HeaderNames.From:
                    writer.WriteFrom(reader.From.AddrSpec.Value, tag);
                    break;

                case HeaderNames.Authorization:
                    break;

                default:
                    writer.WriteHeader(reader, i);
                    break;

                case HeaderNames.Via:
                    via = reader.Headers[i].Value.DeepCopy();
                    break;
                }
            }

            if (reader.ContentLength == int.MinValue)
            {
                writer.WriteContentLength(content.Count);
            }

            writer.WriteCustomHeaders();
            writer.WriteCRLF();

            writer.Write(content);
        }