Fix remote session dialog, peer service, and mobile remote screen
This commit is contained in:
@@ -176,12 +176,9 @@ class _RemoteControlContentState extends State<_RemoteControlContent> {
|
|||||||
|
|
||||||
void _sendCommand(RemoteCommandType type) {
|
void _sendCommand(RemoteCommandType type) {
|
||||||
HapticFeedback.lightImpact();
|
HapticFeedback.lightImpact();
|
||||||
print('🔴 MobileRemoteScreen: Button pressed! Type: $type');
|
|
||||||
appLogger.d('MobileRemoteScreen: Sending command: $type');
|
appLogger.d('MobileRemoteScreen: Sending command: $type');
|
||||||
final provider = context.read<CompanionRemoteProvider>();
|
final provider = context.read<CompanionRemoteProvider>();
|
||||||
print('🔴 Provider isConnected: ${provider.isConnected}');
|
|
||||||
provider.sendCommand(type);
|
provider.sendCommand(type);
|
||||||
print('🔴 sendCommand called');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -247,13 +247,9 @@ class CompanionRemotePeerService {
|
|||||||
});
|
});
|
||||||
|
|
||||||
conn.on('data').listen((data) {
|
conn.on('data').listen((data) {
|
||||||
print('🟡 PeerService: DATA RECEIVED! data type: ${data.runtimeType}');
|
|
||||||
try {
|
try {
|
||||||
print('🟡 Parsing as JSON...');
|
|
||||||
final json = data as Map<String, dynamic>;
|
final json = data as Map<String, dynamic>;
|
||||||
print('🟡 Creating RemoteCommand from JSON...');
|
|
||||||
final command = RemoteCommand.fromJson(json);
|
final command = RemoteCommand.fromJson(json);
|
||||||
print('🟡 Command received: ${command.type} from $peerId');
|
|
||||||
appLogger.d('CompanionRemote: Received command: ${command.type} from $peerId');
|
appLogger.d('CompanionRemote: Received command: ${command.type} from $peerId');
|
||||||
|
|
||||||
// Send acknowledgment for non-ping/pong/ack commands
|
// Send acknowledgment for non-ping/pong/ack commands
|
||||||
@@ -261,7 +257,6 @@ class CompanionRemotePeerService {
|
|||||||
command.type != RemoteCommandType.pong &&
|
command.type != RemoteCommandType.pong &&
|
||||||
command.type != RemoteCommandType.ack &&
|
command.type != RemoteCommandType.ack &&
|
||||||
command.type != RemoteCommandType.deviceInfo) {
|
command.type != RemoteCommandType.deviceInfo) {
|
||||||
print('🟡 Sending ACK for ${command.type}...');
|
|
||||||
final ackCommand = RemoteCommand(
|
final ackCommand = RemoteCommand(
|
||||||
type: RemoteCommandType.ack,
|
type: RemoteCommandType.ack,
|
||||||
deviceId: _myPeerId ?? 'unknown',
|
deviceId: _myPeerId ?? 'unknown',
|
||||||
@@ -269,21 +264,16 @@ class CompanionRemotePeerService {
|
|||||||
data: {'originalCommand': command.type.toString()},
|
data: {'originalCommand': command.type.toString()},
|
||||||
);
|
);
|
||||||
_connection?.send(ackCommand.toJson());
|
_connection?.send(ackCommand.toJson());
|
||||||
print('🟡 ACK sent!');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print('🟡 Adding to _commandReceivedController...');
|
|
||||||
_commandReceivedController.add(command);
|
_commandReceivedController.add(command);
|
||||||
print('🟡 Command added to stream!');
|
|
||||||
|
|
||||||
if (command.type == RemoteCommandType.ping) {
|
if (command.type == RemoteCommandType.ping) {
|
||||||
print('🟡 Responding to ping with pong...');
|
|
||||||
_sendPong(deviceName, platform);
|
_sendPong(deviceName, platform);
|
||||||
} else if (command.type == RemoteCommandType.ack) {
|
} else if (command.type == RemoteCommandType.ack) {
|
||||||
print('✅ RECEIVED ACK from desktop for: ${json['data']?['originalCommand']}');
|
appLogger.d('CompanionRemote: Received ACK for: ${json['data']?['originalCommand']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('🔴 PeerService: Failed to parse command: $e');
|
|
||||||
appLogger.e('CompanionRemote: Failed to parse command', error: e);
|
appLogger.e('CompanionRemote: Failed to parse command', error: e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -374,24 +364,16 @@ class CompanionRemotePeerService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void sendCommand(RemoteCommand command) {
|
void sendCommand(RemoteCommand command) {
|
||||||
print('🔵 PeerService sendCommand called! command.type: ${command.type}');
|
|
||||||
print('🔵 _connection: $_connection');
|
|
||||||
|
|
||||||
if (_connection == null) {
|
if (_connection == null) {
|
||||||
print('🔴 PeerService: No connection!');
|
|
||||||
appLogger.w('CompanionRemote: No connection to send command');
|
appLogger.w('CompanionRemote: No connection to send command');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
print('🔵 Converting command to JSON...');
|
|
||||||
final json = command.toJson();
|
final json = command.toJson();
|
||||||
print('🔵 Sending via connection.send...');
|
|
||||||
_connection!.send(json);
|
_connection!.send(json);
|
||||||
print('🔵 Command sent over wire!');
|
|
||||||
appLogger.d('CompanionRemote: Sent command: ${command.type}');
|
appLogger.d('CompanionRemote: Sent command: ${command.type}');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('🔴 PeerService send FAILED: $e');
|
|
||||||
appLogger.e('CompanionRemote: Failed to send command', error: e);
|
appLogger.e('CompanionRemote: Failed to send command', error: e);
|
||||||
_errorController.add(
|
_errorController.add(
|
||||||
RemotePeerError(
|
RemotePeerError(
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import 'package:flutter/services.dart';
|
|||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:qr_flutter/qr_flutter.dart';
|
import 'package:qr_flutter/qr_flutter.dart';
|
||||||
|
|
||||||
import '../../models/companion_remote/remote_session.dart';
|
|
||||||
import '../../providers/companion_remote_provider.dart';
|
import '../../providers/companion_remote_provider.dart';
|
||||||
import '../../utils/app_logger.dart';
|
import '../../utils/app_logger.dart';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user