-1

Autobahnを使用して wamp を実装するために Android で websocket 接続を作成しようとすると、接続が作成され、すぐに閉じられます。

どうしてこうなった……?の解き方..........?

私のコードの一部を以下に示します

private void start() {
    // TODO Auto-generated method stub
    final String wsuri = "ws://192.168.0.102:8080/ws";
    if (!connection.isConnected()) {
        Log.d("tag", "Not Connected");

    }
    connection.connect(wsuri, new ConnectionHandler() {

        @Override
        public void onOpen() {
            // TODO Auto-generated method stub
            Log.d("tag", "Connected to " + wsuri);
            testPubSub();
        }


        @Override
        public void onClose(int code, String reason) {
            // TODO Auto-generated method stub
            Log.d("tag", "disconnected");


        }

    });
}

protected void testPubSub() {
    // TODO Auto-generated method stub
    connection.subscribe(TOPIC, String.class, new EventHandler() {

        @Override
        public void onEvent(String topicUri, Object event) {
            // TODO Auto-generated method stub
            Log.d("tag", "Event Recieved");
        }
    });
}

以前にマニフェスト ファイルを投稿しなかったことをお詫び申し上げます。その下に与えられた..

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.testwamp"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.INTERNET"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

4

1 に答える 1