# 事件

```javascript
import { Im } from "@relationlabs/im";

myIm.bind(Im.RECEIVE_MSG_OK, (e) => {
    const message = e['im-message']
})
```

|       **Name**      |  **Description**  |                     **Callback Params**                    |
| :-----------------: | :---------------: | :--------------------------------------------------------: |
|    Im.CONNECT\_OK   |   成功连接socket时触发   |                                                            |
|   Im.CONNECT\_ERR   |    socket错误时触发    |                                                            |
|  Im.CONNECT\_CLOSE  |    socket关闭时触发    |                       { reason: '' }                       |
| Im.RECEIVE\_MSG\_OK | 连接socket之后有新消息时触发 | { 'im-message': { channelUuid, sendUuid, from, content } } |
|                     |                   |                                                            |
|         ---         |                   |                                                            |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://relationlabs.gitbook.io/relation-one-api/api-zh/js-sdk/im-js-sdk/events.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
