---
name: "IpcPlayerContext.connect"
mode: "api"
versionRequirements:
  - { name: "Base Library", version: "2.21.8" }
title: "IpcContext.connect - 连接 IPC 设备"
---

## IpcPlayerContext.connect

> [VERSION] Base Library >= 2.21.8

### Description

Connect to the IPC device

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `options` | `IpcCallbackOption` | No | Callback options |

### Return Value

None


### Referenced Types

##### `interface` IpcCallbackOption

| Property | Type | Description |
| --- | --- | --- |
| `success` | `() => void` | Callback invoked on successful API call |
| `fail` | `(result: IpcFailResult) => void` | Callback on failure |
| `complete` | `() => void` | Callback on complete (success or failure) |

##### `interface` IpcFailResult

| Property | Type | Description |
| --- | --- | --- |
| `errorCode` | `string` | Error code |
| `errorMsg` | `string` | Error message |


### Examples

#### Connect to the device

```ts
const ipcCtx = ty.createIpcPlayerContext('deviceId');
ipcCtx.connect({
  success() {
    console.log('Connected successfully');
  },
});
```
