Open alex2390 opened 7 years ago
Is that doing that? public static final String TEST_URL = "ws://192.168.0.149:8080/websocket"; private static final String TAG = "MainActivity"; private HashMap map = new HashMap(); private String uid ="930eecc51d7643d4af67b890565a5759"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); textView = (Button) findViewById(R.id.tv_connect); textView.setOnClickListener(this); map.put("login",uid); }
@Override public void onClick(View v) { //new ConnManager(this,TEST_URL).connect(); createStompClient(); } private void createStompClient() { mStompClient = Stomp.over(WebSocket.class, TEST_URL,map); mStompClient.connect(); Toast.makeText(MainActivity.this, "开始连接 192.168.0.149:8080", Toast.LENGTH_SHORT).show(); mStompClient.lifecycle().subscribe(new Action1<LifecycleEvent>() { @Override public void call(LifecycleEvent lifecycleEvent) { switch (lifecycleEvent.getType()) { case OPENED: Log.d(TAG, "Stomp connection opened"); toast("连接已开启"); break; case ERROR: Log.e(TAG, "Stomp Error", lifecycleEvent.getException()); toast("连接出错"); break; case CLOSED: Log.d(TAG, "Stomp connection closed"); toast("连接关闭"); break; } } });
when i do that, always return closed after a few mintues.
Do you face this issue using OkHttp?
Is that doing that? public static final String TEST_URL = "ws://192.168.0.149:8080/websocket"; private static final String TAG = "MainActivity"; private HashMap map = new HashMap(); private String uid ="930eecc51d7643d4af67b890565a5759"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); textView = (Button) findViewById(R.id.tv_connect); textView.setOnClickListener(this); map.put("login",uid); }
when i do that, always return closed after a few mintues.