public Hashtable HandleDialplanRequest(string Context, string Realm, Hashtable request)
        {
             m_log.DebugFormat("[FreeSwitchVoice] HandleDialplanRequest called with {0}",request.ToString());
             
             Hashtable response = new Hashtable();
             
             foreach (DictionaryEntry item in request)
             {
                m_log.InfoFormat("[FreeSwitchDirectory] requestBody item {0} {1}",item.Key, item.Value);
             }

             string requestcontext = (string) request["Hunt-Context"];
             response["content_type"] = "text/xml";
             response["keepalive"] = false;
            response["int_response_code"] = 200;
            if (Context != String.Empty && Context != requestcontext)
            {
                m_log.Debug("[FreeSwitchDirectory] returning empty as it's for another context");
                response["str_response_string"] = "";
            } else {
                response["str_response_string"] = String.Format(@"<?xml version=""1.0"" encoding=""utf-8""?>
                   <document type=""freeswitch/xml"">
                     <section name=""dialplan"">
                     <context name=""{0}"">" + 
               
/*                           <!-- dial via SIP uri -->
                            <extension name=""sip_uri"">
                                   <condition field=""destination_number"" expression=""^sip:(.*)$"">
                                   <action application=""bridge"" data=""sofia/${use_profile}/$1""/>
                                   <!--<action application=""bridge"" data=""$1""/>-->
                                   </condition>
                           </extension>*/
               
                           @"<extension name=""opensim_conferences"">
                                   <condition field=""destination_number"" expression=""^confctl-(.*)$"">
                                           <action application=""answer""/>
                                           <action application=""conference"" data=""$1-{1}@{0}""/>
                                   </condition>
                           </extension>
                       
                           <extension name=""opensim_conf"">
                                   <condition field=""destination_number"" expression=""^conf-(.*)$"">
                                           <action application=""answer""/>
                                           <action application=""conference"" data=""$1-{1}@{0}""/>
                                   </condition>
                           </extension>
               
                           <extension name=""avatar"">
                                   <condition field=""destination_number"" expression=""^(x.*)$"">
                                           <action application=""bridge"" data=""user/$1""/>
                                   </condition>
                           </extension>
               
                     </context>
                   </section>
                   </document>", Context, Realm);
            }
             
            return response;   
        }    
        public ActionResult GetUrlScheme(int tickid, string ntype = "gclub")
        {
            Hashtable ht       = new System.Collections.Hashtable();
            var       curtoken = Senparc.Weixin.MP.Containers.AccessTokenContainer.TryGetAccessToken("当前小程序APPID", "当前小程序秘钥");

            ht.Add("data", GetGenerateScheme(curtoken));
            return(Content(ht.ToString()));
        }
Esempio n. 3
0
        public Hashtable HandleDialplanRequest(Hashtable request)
        {
             m_log.DebugFormat("[FreeSwitchVoice] HandleDialplanRequest called with {0}",request.ToString());
             
             Hashtable response = new Hashtable();
             
             foreach (DictionaryEntry item in request)
             {
                m_log.InfoFormat("[FreeSwitchDirectory] requestBody item {0} {1}",item.Key, item.Value);
             }

             response["content_type"] = "text/xml";
             response["keepalive"] = false;
             response["int_response_code"] = 200;
             response["str_response_string"] = @"<?xml version=""1.0"" encoding=""utf-8""?>
                   <document type=""freeswitch/xml"">
                     <section name=""dialplan"">
                  <context name=""default"">
               
                        <!-- dial via SIP uri -->
                            <extension name=""sip_uri"">
                                   <condition field=""destination_number"" expression=""^sip:(.*)$"">
                                   <action application=""bridge"" data=""sofia/${use_profile}/$1""/>
                                   <!--<action application=""bridge"" data=""$1""/>-->
                                   </condition>
                        </extension>
               
                        <extension name=""opensim_conferences"">
                                   <condition field=""destination_number"" expression=""^confctl-(.*)$"">
                                           <action application=""answer""/>
                                        <action application=""conference"" data=""$1-${domain_name}@default""/>
                                   </condition>
                           </extension>
                       
                           <extension name=""opensim_conf"">
                                   <condition field=""destination_number"" expression=""^conf-(.*)$"">
                                           <action application=""answer""/>
                                           <action application=""conference"" data=""$1-${domain_name}@default""/>
                                   </condition>
                           </extension>
               
                           <extension name=""avatar"">
                                   <condition field=""destination_number"" expression=""^(x.*)$"">
                                           <action application=""bridge"" data=""user/$1""/>
                                   </condition>
                           </extension>
               
                     </context>
                   </section>
                </document>";
             
            return response;   
        }    
Esempio n. 4
0
        public async Task <ActionResult> GetUrlScheme(int tickid, string ntype = "gclub")
        {
            if (!HttpContext.Request.IsLocal())
            {
                return(Content("此接口为内部接口,请在服务器本地调用!"));
            }

            Hashtable ht          = new System.Collections.Hashtable();
            var       weixinAppId = Senparc.Weixin.Config.SenparcWeixinSetting.MpSetting.WeixinAppId;
            var       jumpWxa     = new Weixin.WxOpen.AdvancedAPIs.UrlScheme.GenerateSchemeJumpWxa("", null);
            var       schmeResult = await Senparc.Weixin.WxOpen.AdvancedAPIs.UrlSchemeApi.GenerateSchemeAsync(weixinAppId, jumpWxa, false, null);

            ht.Add("data", schmeResult);

            return(Content(ht.ToString()));
        }
        public byte[] HandleDirectoryRequest(Hashtable request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            string domain = (string)request["domain"];
            if (domain != m_freeSwitchRealm)
            {
                httpResponse.ContentType = "text/xml";
                httpResponse.StatusCode = 200;
                return MainServer.BadRequest;
            }
            else
            {
                MainConsole.Instance.DebugFormat("[FreeSwitchDirectory] HandleDirectoryRequest called with {0}", request.ToString());

                // information in the request we might be interested in

                // Request 1 sip_auth for users account

                //Event-Calling-Function=sofia_reg_parse_auth
                //Event-Calling-Line-Number=1494
                //action=sip_auth
                //sip_user_agent=Vivox-SDK-2.1.3010.6151-Mac%20(Feb-11-2009/16%3A42%3A41)
                //sip_auth_username=xhZuXKmRpECyr2AARJYyGgg%3D%3D  (==)
                //sip_auth_realm=9.20.151.43
                //sip_contact_user=xhZuXKmRpECyr2AARJYyGgg%3D%3D (==)
                //sip_contact_host=192.168.0.3    // this shouldnt really be a local IP, investigate STUN servers
                //sip_to_user=xhZuXKmRpECyr2AARJYyGgg%3D%3D
                //sip_to_host=9.20.151.43
                //sip_auth_method=REGISTER
                //user=xhZuXKmRpECyr2AARJYyGgg%3D%3D
                //domain=9.20.151.43
                //ip=9.167.220.137    // this is the correct IP rather than sip_contact_host above when through a vpn or NAT setup

                foreach (DictionaryEntry item in request)
                {
                    MainConsole.Instance.InfoFormat("[FreeSwitchDirectory] requestBody item {0} {1}", item.Key, item.Value);
                }

                string eventCallingFunction = (string)request["Event-Calling-Function"];
                if (eventCallingFunction == null)
                {
                    eventCallingFunction = "sofia_reg_parse_auth";
                }

                if (eventCallingFunction.Length == 0)
                {
                    eventCallingFunction = "sofia_reg_parse_auth";
                }

                if (eventCallingFunction == "sofia_reg_parse_auth")
                {
                    string sipAuthMethod = (string)request["sip_auth_method"];

                    if (sipAuthMethod == "REGISTER")
                    {
                        return HandleRegister(m_freeSwitchContext, m_freeSwitchRealm, request, httpRequest, httpResponse);
                    }
                    else if (sipAuthMethod == "INVITE")
                    {
                        return HandleInvite(m_freeSwitchContext, m_freeSwitchRealm, request, httpRequest, httpResponse);
                    }
                    else
                    {
                        MainConsole.Instance.ErrorFormat("[FreeSwitchVoice] HandleDirectoryRequest unknown sip_auth_method {0}", sipAuthMethod);
                        httpResponse.ContentType = "text/xml";
                        httpResponse.StatusCode = 404;
                        return MainServer.BadRequest;
                    }
                }
                else if (eventCallingFunction == "switch_xml_locate_user")
                {
                    return HandleLocateUser(m_freeSwitchRealm, request, httpRequest, httpResponse);
                }
                else if (eventCallingFunction == "user_data_function") // gets called when an avatar to avatar call is made
                {
                    return HandleLocateUser(m_freeSwitchRealm, request, httpRequest, httpResponse);
                }
                else if (eventCallingFunction == "user_outgoing_channel")
                {
                    return HandleRegister(m_freeSwitchContext, m_freeSwitchRealm, request, httpRequest, httpResponse);
                }
                else if (eventCallingFunction == "config_sofia") // happens once on freeswitch startup
                {
                    return HandleConfigSofia(m_freeSwitchContext, m_freeSwitchRealm, request, httpRequest, httpResponse);
                }
                else if (eventCallingFunction == "switch_load_network_lists")
                {
                    //response = HandleLoadNetworkLists(request);
                    httpResponse.ContentType = "text/xml";
                    httpResponse.StatusCode = 404;
                    return MainServer.BadRequest;
                }
                else
                {
                    MainConsole.Instance.ErrorFormat("[FreeSwitchVoice] HandleDirectoryRequest unknown Event-Calling-Function {0}", eventCallingFunction);
                    httpResponse.ContentType = "text/xml";
                    httpResponse.StatusCode = 404;
                    return MainServer.BadRequest;
                }
            }
        }
        public byte[] HandleDialplanRequest(Hashtable request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            MainConsole.Instance.DebugFormat("[FreeSwitchVoice] HandleDialplanRequest called with {0}", request.ToString());

            string requestcontext = (string)request["Hunt-Context"];
            httpResponse.ContentType = "text/xml";
            httpResponse.StatusCode = 200;

            if (m_freeSwitchContext != String.Empty && m_freeSwitchContext != requestcontext)
            {
                MainConsole.Instance.Debug("[FreeSwitchDirectory] returning empty as it's for another context");
                return MainServer.BadRequest;
            }
            else
            {
                return Encoding.UTF8.GetBytes(String.Format(@"<?xml version=""1.0"" encoding=""utf-8""?>
                   <document type=""freeswitch/xml"">
                     <section name=""dialplan"">
                     <context name=""{0}"">" +

            /*                           <!-- dial via SIP uri -->
                            <extension name=""sip_uri"">
                                   <condition field=""destination_number"" expression=""^sip:(.*)$"">
                                   <action application=""bridge"" data=""sofia/${use_profile}/$1""/>
                                   <!--<action application=""bridge"" data=""$1""/>-->
                                   </condition>
                           </extension>*/

                           @"<extension name=""opensim_conferences"">
                                   <condition field=""destination_number"" expression=""^confctl-(.*)$"">
                                           <action application=""answer""/>
                                           <action application=""conference"" data=""$1-{1}@{0}""/>
                                   </condition>
                           </extension>

                           <extension name=""opensim_conf"">
                                   <condition field=""destination_number"" expression=""^conf-(.*)$"">
                                           <action application=""answer""/>
                                           <action application=""conference"" data=""$1-{1}@{0}""/>
                                   </condition>
                           </extension>

                           <extension name=""avatar"">
                                   <condition field=""destination_number"" expression=""^(x.*)$"">
                                           <action application=""bridge"" data=""user/$1""/>
                                   </condition>
                           </extension>

                     </context>
                   </section>
                   </document>", m_freeSwitchContext, m_freeSwitchRealm));
            }
        }
Esempio n. 7
0
        //
        // Make external XMLRPC request
        //
        private Hashtable GenericXMLRPCRequest(Hashtable ReqParams, string method)
        {
            ArrayList SendParams = new ArrayList();
            SendParams.Add(ReqParams);

            // Send Request
            XmlRpcResponse Resp;
            try
            {
                XmlRpcRequest Req = new XmlRpcRequest(method, SendParams);
                Resp = Req.Send(m_ProfileServer, 30000);
            }

            catch (WebException ex)
            {
                m_log.ErrorFormat("[PROFILE]: Unable to connect to Profile Server {0}.  Exception {1}", m_ProfileServer, ex);
                Hashtable ErrorHash = new Hashtable();
                ErrorHash["success"] = false;
                ErrorHash["errorMessage"] = "WEB Connecton Error.";
                ErrorHash["errorURI"] = "";

                return ErrorHash;
            }

            catch (SocketException ex)
            {
                m_log.ErrorFormat("[PROFILE]: Unable to connect to Profile Server {0}. Method {1}, params {2}. Exception {3}",
                                                            m_ProfileServer, method, ReqParams, ex);
                Hashtable ErrorHash = new Hashtable();
                ErrorHash["success"] = false;
                ErrorHash["errorMessage"] = "Network Socket Error.";
                ErrorHash["errorURI"] = "";

                return ErrorHash;
            }

            catch (XmlException ex)
            {
                m_log.ErrorFormat("[PROFILE]: Unable to connect to Profile Server {0}. Method {1}, params {2}. Exception {3}",
                                                            m_ProfileServer, method, ReqParams.ToString(), ex);
                Hashtable ErrorHash = new Hashtable();
                ErrorHash["success"] = false;
                ErrorHash["errorMessage"] = "XML Parse Error.";
                ErrorHash["errorURI"] = "";

                return ErrorHash;
            }

            if (Resp.IsFault)
            {
                Hashtable ErrorHash = new Hashtable();
                ErrorHash["success"] = false;
                ErrorHash["errorMessage"] = "Response Fault.";
                ErrorHash["errorURI"] = "";
                return ErrorHash;
            }
            Hashtable RespData = (Hashtable)Resp.Value;

            return RespData;
        }