✨ Windows RPC IPC
This commit is contained in:
		@@ -79,6 +79,11 @@ class ActivityRpcServer {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  // Find available IPC socket path
 | 
					  // Find available IPC socket path
 | 
				
			||||||
  Future<String> _findAvailableIpcPath() async {
 | 
					  Future<String> _findAvailableIpcPath() async {
 | 
				
			||||||
 | 
					    if (Platform.isWindows) {
 | 
				
			||||||
 | 
					      // Use TCP sockets on Windows for IPC (simpler and more compatible)
 | 
				
			||||||
 | 
					      return _findAvailableTcpPort();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Build list of directories to try, with macOS-specific handling
 | 
					    // Build list of directories to try, with macOS-specific handling
 | 
				
			||||||
    final baseDirs = <String>[];
 | 
					    final baseDirs = <String>[];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -145,6 +150,35 @@ class ActivityRpcServer {
 | 
				
			|||||||
    );
 | 
					    );
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Find available TCP port for Windows IPC
 | 
				
			||||||
 | 
					  Future<String> _findAvailableTcpPort() async {
 | 
				
			||||||
 | 
					    // Use ports in the range 6463-6472 (same as WebSocket server)
 | 
				
			||||||
 | 
					    for (int port = 6463; port <= 6472; port++) {
 | 
				
			||||||
 | 
					      try {
 | 
				
			||||||
 | 
					        final socket = await ServerSocket.bind(
 | 
				
			||||||
 | 
					          InternetAddress.loopbackIPv4,
 | 
				
			||||||
 | 
					          port,
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					        socket.close();
 | 
				
			||||||
 | 
					        developer.log(
 | 
				
			||||||
 | 
					          'IPC TCP socket will be created on port: $port',
 | 
				
			||||||
 | 
					          name: kRpcIpcLogPrefix,
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					        return port.toString(); // Return as string to match existing interface
 | 
				
			||||||
 | 
					      } catch (e) {
 | 
				
			||||||
 | 
					        // Port not available, try next
 | 
				
			||||||
 | 
					        if (port == 6463) {
 | 
				
			||||||
 | 
					          developer.log(
 | 
				
			||||||
 | 
					            'IPC TCP port $port not available: $e',
 | 
				
			||||||
 | 
					            name: kRpcIpcLogPrefix,
 | 
				
			||||||
 | 
					          );
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        continue;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    throw Exception('No available IPC TCP ports found');
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Start the WebSocket server
 | 
					  // Start the WebSocket server
 | 
				
			||||||
  Future<void> start() async {
 | 
					  Future<void> start() async {
 | 
				
			||||||
    int port = portRange[0];
 | 
					    int port = portRange[0];
 | 
				
			||||||
@@ -197,12 +231,27 @@ class ActivityRpcServer {
 | 
				
			|||||||
    final shouldStartIpc = !Platform.isMacOS;
 | 
					    final shouldStartIpc = !Platform.isMacOS;
 | 
				
			||||||
    if (shouldStartIpc) {
 | 
					    if (shouldStartIpc) {
 | 
				
			||||||
      try {
 | 
					      try {
 | 
				
			||||||
 | 
					        if (Platform.isWindows) {
 | 
				
			||||||
 | 
					          // Use TCP socket on Windows
 | 
				
			||||||
 | 
					          final ipcPortStr = await _findAvailableIpcPath();
 | 
				
			||||||
 | 
					          final ipcPort = int.parse(ipcPortStr);
 | 
				
			||||||
 | 
					          _ipcServer = await ServerSocket.bind(
 | 
				
			||||||
 | 
					            InternetAddress.loopbackIPv4,
 | 
				
			||||||
 | 
					            ipcPort,
 | 
				
			||||||
 | 
					          );
 | 
				
			||||||
 | 
					          developer.log(
 | 
				
			||||||
 | 
					            'IPC listening on TCP port $ipcPort',
 | 
				
			||||||
 | 
					            name: kRpcIpcLogPrefix,
 | 
				
			||||||
 | 
					          );
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					          // Use Unix socket on other platforms
 | 
				
			||||||
          final ipcPath = await _findAvailableIpcPath();
 | 
					          final ipcPath = await _findAvailableIpcPath();
 | 
				
			||||||
          _ipcServer = await ServerSocket.bind(
 | 
					          _ipcServer = await ServerSocket.bind(
 | 
				
			||||||
            InternetAddress(ipcPath, type: InternetAddressType.unix),
 | 
					            InternetAddress(ipcPath, type: InternetAddressType.unix),
 | 
				
			||||||
            0,
 | 
					            0,
 | 
				
			||||||
          );
 | 
					          );
 | 
				
			||||||
          developer.log('IPC listening at $ipcPath', name: kRpcIpcLogPrefix);
 | 
					          developer.log('IPC listening at $ipcPath', name: kRpcIpcLogPrefix);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        _ipcServer!.listen((Socket socket) {
 | 
					        _ipcServer!.listen((Socket socket) {
 | 
				
			||||||
          _onIpcConnection(socket);
 | 
					          _onIpcConnection(socket);
 | 
				
			||||||
@@ -213,7 +262,7 @@ class ActivityRpcServer {
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      developer.log(
 | 
					      developer.log(
 | 
				
			||||||
        'IPC server disabled on macOS in production mode due to sandboxing',
 | 
					        'IPC server disabled on macOS due to sandboxing',
 | 
				
			||||||
        name: kRpcIpcLogPrefix,
 | 
					        name: kRpcIpcLogPrefix,
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2765,7 +2765,7 @@ packages:
 | 
				
			|||||||
    source: hosted
 | 
					    source: hosted
 | 
				
			||||||
    version: "1.3.0"
 | 
					    version: "1.3.0"
 | 
				
			||||||
  win32:
 | 
					  win32:
 | 
				
			||||||
    dependency: transitive
 | 
					    dependency: "direct main"
 | 
				
			||||||
    description:
 | 
					    description:
 | 
				
			||||||
      name: win32
 | 
					      name: win32
 | 
				
			||||||
      sha256: "66814138c3562338d05613a6e368ed8cfb237ad6d64a9e9334be3f309acfca03"
 | 
					      sha256: "66814138c3562338d05613a6e368ed8cfb237ad6d64a9e9334be3f309acfca03"
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user