Example #1
0
 private static Address RouteService(Message request, Block Block, string toId, string fromId)
 {
     string callID = request.First("Call-ID").ToString();
     if (_activeFlows.ContainsKey(callID))
     {
         ActiveFlow af = _activeFlows[callID];
         af.LastRequest = request;
         af.LastBlock = Block;
     }
     else
     {
         ActiveFlow af = new ActiveFlow();
         af.OriginalRequest = request;
         af.LastRequest = request;
         af.LastBlock = Block;
        _activeFlows.Add(callID,af);
     }
     Address dest = new Address(Block.DestURI);
     return dest;
 }
Example #2
0
        private static void RouteNewMessage(Message request, Proxy pua)
        {
            SIPURI to = request.Uri;
            string toID = to.User + "@" + to.Host;

            Address from = (Address)(request.First("From").Value);
            string fromID = from.Uri.User + "@" + from.Uri.Host;

            List<ServiceFlow> toUserFlows = GetUserBlocks(toID);
            List<ServiceFlow> fromUserFlows = GetUserBlocks(fromID);

            Address dest = new Address(to.ToString());

            foreach (ServiceFlow serviceFlow in toUserFlows)
            {
                if (serviceFlow.Blocks.Count > 0)
                {
                    Block firstBlock = serviceFlow.Blocks[serviceFlow.FirstBlockGUID];
                    Address temp_dest = CheckServiceBlock(request, firstBlock, toID, fromID);
                    if (temp_dest != null)
                    {
                        dest = temp_dest;
                        break;
                    }
                }
                else continue;
            }

            Message proxiedMessage = pua.CreateRequest(request.Method, dest, true, true);
            proxiedMessage.First("To").Value = dest;
            string callID = proxiedMessage.First("Call-ID").ToString();
            ActiveFlow af = new ActiveFlow ();
            af.LastRequest = proxiedMessage;
            _activeFlows[callID] = af;
            pua.SendRequest(proxiedMessage);
        }