介绍:
利用okHttp中自带的mock web server在AndroidStudio测试WebSocketServer
注意:
1.只能在本机回环测试
2. 端口号每次都是随机变化,client端每次都需要更改端口号才可以使用。
build.gradle:
compile 'com.squareup.okhttp3:okhttp:3.10.0'
compile 'com.squareup.okhttp3:mockwebserver:3.10.0'
AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET"/>
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
</<