Commit eaa410eb authored by Chengzhao Li's avatar Chengzhao Li
Browse files

- peer disconnect system message should not be sent to the disconnected device

- add more log
parent da16274a
......@@ -80,6 +80,10 @@ public class ChatActivity extends Activity {
String msg = getChatMsg();
if (msg.length() > 0) {
MultiplayerController.getInstance().sendDataToPeer(msg.getBytes(), txtPlayer1.getText().toString(), NCMCSession.NCMCSessionSendDataUnreliable);
MultiplayerController.getInstance().sendDataToPeer(msg.getBytes(), txtPlayer1.getText().toString(), NCMCSession.NCMCSessionSendDataUnreliable);
MultiplayerController.getInstance().sendDataToPeer(msg.getBytes(), txtPlayer1.getText().toString(), NCMCSession.NCMCSessionSendDataUnreliable);
MultiplayerController.getInstance().sendDataToPeer(msg.getBytes(), txtPlayer1.getText().toString(), NCMCSession.NCMCSessionSendDataUnreliable);
MultiplayerController.getInstance().sendDataToPeer(msg.getBytes(), txtPlayer1.getText().toString(), NCMCSession.NCMCSessionSendDataUnreliable);
}
}
});
......
......@@ -204,6 +204,7 @@ public class MultiplayerController {
if (stringForMCPeerDisplayName(pid.getDisplayName()).equalsIgnoreCase(stringForMCPeerDisplayName(peerID.getDisplayName()))) {
currentSessionPlayerIDs.remove(pid);
broadcastStatus(BLE_BROADCAST_UPDATE_PLAYERLIST);
break;
}
}
......
......@@ -407,7 +407,7 @@ import java.util.UUID;
boolean isFound = false;
for (ParcelUuid uuid : serviceUUIDs) {
Log.d(TAG, "UUUUID: " + uuid.toString());
//Log.d(TAG, "UUUUID: " + uuid.toString());
if (uuid.toString().equalsIgnoreCase(mSession.serviceID)) {
isFound = true;
break;
......@@ -670,6 +670,7 @@ import java.util.UUID;
}
private void connectToPeripheral(NCMCPeripheralInfo info) {
Log.d(TAG, "connectToPeripheral: " + info.name + " deviceAddress: " + info.device.getAddress());
if (Build.VERSION.SDK_INT>= Build.VERSION_CODES.M) {
info.bluetoothGatt = info.device.connectGatt(mContext, false, mGattCallback, BluetoothDevice.TRANSPORT_LE);
} else {
......
......@@ -138,7 +138,7 @@ public class NCMCSession {
byte[] deviceData = encodeDeviceInfo(info);
byte[] sysData = packSystemMessage(SYSMSG_CENTRAL_PERIPHERAL_DEVICE_DISCONNECTED, deviceData);
for (NCMCDeviceInfo peripheralInfo : this.connectedDevices) {
if (peripheralInfo.uniqueID != 0) {
if (peripheralInfo.uniqueID != 0 && peripheralInfo.uniqueID != info.uniqueID) {
NCMCBluetoothLEManager.getInstance().sendCentralDataToPeripheral(sysData, peripheralInfo.identifier, NCMCSessionSendDataReliable);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment