public RequestProxyFactory(ProxyServerTU parent, IncomingMessageEx request)
            {
                this.parent  = parent;
                this.request = request;

                this.requestProxy = null;
            }
示例#2
0
        private void CancelClients(RequestProxy requestProxy, SipMessageReader message)
        {
            lock (requestProxy)
            {
                var proxies = requestProxy.GetAllProxie();

                for (int i = 0; i < proxies.Count; i++)
                {
                    if (proxies[i].IsFinalReceived == false && proxies[i].IsCancelSent == false)
                    {
                        proxies[i].IsCancelSent = true;

                        if (Transaction.GetTransactionKind(proxies[i].TransactionId) == Transaction.Kind.InviteClient)
                        {
                            var writer = GetWriter();
                            proxies[i].GenerateCancel(writer, message);

                            int transactionKId = Transaction.GetRelaytedCancelClientKId(proxies[i].TransactionId);

                            requestProducer.SendRequest(proxies[i].ToConnectionAddresses, writer, transactionKId);
                        }
                    }
                }
            }
        }
示例#3
0
        private void ForwardRequest(IProxie proxie, RequestProxy requestProxy, SipMessageReader reader)
        {
            #region vars...
            var serverConnectionAddresses = requestProxy.ConnectionAddresses;
            var clientConnectionAddresses = proxie.ToConnectionAddresses;
            int serverTransactionId       = requestProxy.ServerTransactionId;
            int clientTransactionId       = proxie.TransactionId;
            var method  = reader.Method;
            var content = requestProxy.Content;
            #endregion

            clientTransactionIds.Add(clientTransactionId, serverTransactionId);

            if (method == Methods.Ackm)
            {
                proxie.IsFinalReceived = true;
            }

            requestProxy.AddProxie(proxie);

            var writer = GetWriter();
            proxie.GenerateForwardedRequest(writer, reader, content, serverConnectionAddresses, serverTransactionId);
            requestProducer.SendRequest(clientConnectionAddresses, writer, clientTransactionId, serverTransactionId);

            proxie.TimerC = (method == Methods.Invitem) ?
                            timerC.Add(new ServerClientId(serverTransactionId, clientTransactionId)) : timerC.InvalidTimerIndex;
        }
			public RequestProxyFactory(ProxyServerTU parent, IncomingMessageEx request)
			{
				this.parent = parent;
				this.request = request;

				this.requestProxy = null;
			}
示例#5
0
        private SipMessageReader ParseHeaders(RequestProxy requestProxy)
        {
            if (readerInternal == null)
            {
                readerInternal = new SipMessageReader();
            }

            readerInternal.SetDefaultValue();
            readerInternal.Parse(requestProxy.Headers.Array, requestProxy.Headers.Offset, requestProxy.Headers.Count);
            readerInternal.SetArray(requestProxy.Headers.Array);

            return(readerInternal);
        }
示例#6
0
 private void SendBestIfAllFinalRecived(RequestProxy requestProxy)
 {
     if (requestProxy != null)
     {
         if (requestProxy.IsAllRequestsSent && requestProxy.IsAllResponsesReceived)
         {
             var bestResponse = requestProxy.DetachBestResponse();
             if (bestResponse != null)
             {
                 SendResponse(requestProxy.ConnectionAddresses, requestProxy.ServerTransactionId, bestResponse);
             }
         }
     }
 }
示例#7
0
        private void RemoveIfFinished(RequestProxy requestProxy)
        {
            if (requestProxy != null)
            {
                if (requestProxy.IsAllRequestsSent && requestProxy.IsAllResponsesReceived)
                {
                    var proxies = requestProxy.GetAllProxie();
                    for (int i = 0; i < proxies.Count; i++)
                    {
                        clientTransactionIds.Remove(proxies[i].TransactionId);
                    }

                    requestProxy.Dispose();
                    requestProxyes.Remove(requestProxy.ServerTransactionId);
                }
            }
        }
			private void CreateLockedRequestProxy()
			{
				if (requestProxy == null)
				{
					requestProxy = new RequestProxy(request);
					Monitor.Enter(requestProxy);

					if (request.Reader.Method != Methods.Ackm)
						parent.requestProxyes.Add(requestProxy.ServerTransactionId, requestProxy);

					if (request.Reader.Method == Methods.Invitem)
					{
						var writer = parent.GetWriter();
						writer.WriteResponse(request.Reader, StatusCodes.Trying);
						parent.SendResponse(request, writer);
					}
				}
			}
            private void CreateLockedRequestProxy()
            {
                if (requestProxy == null)
                {
                    requestProxy = new RequestProxy(request);
                    Monitor.Enter(requestProxy);

                    if (request.Reader.Method != Methods.Ackm)
                    {
                        parent.requestProxyes.Add(requestProxy.ServerTransactionId, requestProxy);
                    }

                    if (request.Reader.Method == Methods.Invitem)
                    {
                        var writer = parent.GetWriter();
                        writer.WriteResponse(request.Reader, StatusCodes.Trying);
                        parent.SendResponse(request, writer);
                    }
                }
            }