如何在sock代理后面使用Twilio AndroidSDK

时间:2017-01-31 00:32:43

标签: android twilio

我将使用Twilio AndroidSDK。 我需要在socks5代理后面使用Twilio AndroidSDK。

我在twilio-mobile-quickstart中的ClientActivity.java下编写了这段代码 https://www.twilio.com/docs/quickstart/php/android-client

public static class MyProxySelector extends ProxySelector {
    private ProxySelector delegate;

    public MyProxySelector(ProxySelector delegate){
        this.delegate = delegate;
    }

    @Override
    public List<Proxy> select(URI uri){
        Proxy proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress("[MY-SOCKS5-SERVER-IP HERE]",1080));
        List<Proxy> select = new ArrayList<Proxy>();
        select.add(proxy);
        System.out.println("Use Socks5 Proxy Server: " + select);
        return select;
    }

    @Override
    public void connectFailed(URI uri, SocketAddress sa, IOException ioe){
        throw new UnsupportedOperationException("Not Supported yet");
    }


}

并在&#34; // proxyselector&#34;之间添加初始化代码ProxySelector。和&#34; // eol&#34;

/*
 * Initialize the Twilio Client SDK
 */
private void initializeTwilioClientSDK() {

    if (!Twilio.isInitialized()) {
        // proxyselector
        ProxySelector proxySelector = ProxySelector.getDefault();

        ProxySelector myProxySelector = new MyProxySelector(proxySelector);
        ProxySelector.setDefault(myProxySelector);
        // eof

        Twilio.initialize(getApplicationContext(), new Twilio.InitListener() {

任何人都可能知道我哪里做错了?提前谢谢。

----添加信息:Android Monitor日志

01-31 10:34:40.906 20853-20939/com.twilio.client.quickstart D/libGLESv1: DTS_GLAPI : DTS is not allowed for Package : com.twilio.client.quickstart
01-31 10:34:40.926 20853-20954/com.twilio.client.quickstart I/System.out: Use Default Proxy List[SOCKS@/59.106.213.62:1080]
<snip>
01-31 10:34:41.606 20853-20853/com.twilio.client.quickstart I/PJSIP: 10:34:41.618    pjsua_acc.c  ..Contact for acc 1 updated for SIP outbound: <sip:phtest@MY-CLIENT-ANDROID-IP:38888;transport=TLS;ob>;reg-id=1;+sip.instance="<urn:uuid:00000000-0000-0000-0000-0000e922f243>"

0 个答案:

没有答案