[Update]Netty支持多channel通信和业务身份绑定

This commit is contained in:
chenfufeng
2022-02-18 18:02:29 +08:00
parent fc89d1a34b
commit 6e850b0cab
8 changed files with 217 additions and 181 deletions

View File

@@ -45,7 +45,7 @@ public class NettyClientActivity extends AppCompatActivity implements View.OnCli
setContentView(R.layout.activity_netty_client);
findViews();
initView();
NSDNettyManager.getInstance().searchAndConnectServer(this, this);
NSDNettyManager.getInstance().searchAndConnectServer(this, "0", this);
}
private void initView() {
@@ -107,21 +107,21 @@ public class NettyClientActivity extends AppCompatActivity implements View.OnCli
}
@Override
public void onMessageResponseClient(MogoProtocolMsg msg, int index) {
public void onMessageResponseClient(MogoProtocolMsg msg, String sign) {
String result = msg.toString();
Log.e(TAG, "onMessageResponse:" + result);
logRece(result);
}
@Override
public void onClientStatusConnectChanged(final int statusCode, final int index) {
public void onClientStatusConnectChanged(final int statusCode, final String sign) {
runOnUiThread(() -> {
if (statusCode == ConnectState.STATUS_CONNECT_SUCCESS) {
Log.e(TAG, "STATUS_CONNECT_SUCCESS:");
mConnect.setText("DisConnect:" + index);
mConnect.setText("DisConnect:" + sign);
} else {
Log.e(TAG, "onServiceStatusConnectChanged:" + statusCode);
mConnect.setText("Connect:" + index);
mConnect.setText("Connect:" + sign);
}
});

View File

@@ -152,8 +152,8 @@ public class NettyServerActivity extends AppCompatActivity implements View.OnCli
}
@Override
public void onMessageResponseServer(MogoProtocolMsg msg, String channelId) {
Log.e(TAG,"onMessageResponseServer:channelId:" + channelId);
public void onMessageResponseServer(MogoProtocolMsg msg, Channel channel) {
Log.e(TAG,"onMessageResponseServer:channelId:" + channel.id().asShortText());
String result = msg.toString();
Log.e(TAG, "onMessageResponse:" + result);