(
udid: &str,
target_id: &str,
socket: WebSocket,
)
| 433 | } |
| 434 | |
| 435 | async fn attach_websocket_inner( |
| 436 | udid: &str, |
| 437 | target_id: &str, |
| 438 | socket: WebSocket, |
| 439 | ) -> Result<(), AppError> { |
| 440 | let (app_id, page_id) = decode_target_id(target_id)?; |
| 441 | let webkit_socket = discover_webinspector_socket(udid).await?.ok_or_else(|| { |
| 442 | AppError::not_found(format!( |
| 443 | "No WebKit Remote Inspector socket was found for simulator {udid}." |
| 444 | )) |
| 445 | })?; |
| 446 | let stream = timeout(WEBKIT_IO_TIMEOUT, UnixStream::connect(&webkit_socket.path)) |
| 447 | .await |
| 448 | .map_err(|_| AppError::native("Timed out connecting to simulator webinspectord."))? |
| 449 | .map_err(|error| { |
| 450 | AppError::native(format!( |
| 451 | "Unable to connect to simulator webinspectord at {}: {error}", |
| 452 | webkit_socket.path |
| 453 | )) |
| 454 | })?; |
| 455 | |
| 456 | let connection_id = new_remote_inspector_id(); |
| 457 | let sender_id = connection_id.clone(); |
| 458 | let (mut inspector_reader, mut inspector_writer) = stream.into_split(); |
| 459 | send_rpc( |
| 460 | &mut inspector_writer, |
| 461 | "_rpc_reportIdentifier:", |
| 462 | rpc_args(&connection_id), |
| 463 | ) |
| 464 | .await?; |
| 465 | sleep(WEBKIT_SOCKET_ACTIVATION_DELAY).await; |
| 466 | prepare_webkit_target_for_attach( |
| 467 | &mut inspector_reader, |
| 468 | &mut inspector_writer, |
| 469 | &connection_id, |
| 470 | &app_id, |
| 471 | page_id, |
| 472 | ) |
| 473 | .await?; |
| 474 | send_forward_indicate_webview( |
| 475 | &mut inspector_writer, |
| 476 | &connection_id, |
| 477 | &app_id, |
| 478 | page_id, |
| 479 | true, |
| 480 | ) |
| 481 | .await?; |
| 482 | send_forward_indicate_webview( |
| 483 | &mut inspector_writer, |
| 484 | &connection_id, |
| 485 | &app_id, |
| 486 | page_id, |
| 487 | false, |
| 488 | ) |
| 489 | .await?; |
| 490 | send_forward_socket_setup( |
| 491 | &mut inspector_writer, |
| 492 | &connection_id, |
no test coverage detected