flooim#
flooim#
- flooim
- .flooim(config) ⇒
object - .login(opt)
- .qrlogin(opt)
- .tokenLogin(user_id, token)
- .idLogin(opt)
- .isLogin() ⇒
boolean - .on(options, ext)
- .off(options, ext)
- .logout()
- .setLogLevel(logLevel)
flooim.flooim(config) ⇒ object#
初始化SDK
Kind: static method of flooim
Returns: object - flooim物件
| Param | Type | Description |
|---|---|---|
| config | object | SDK初始化設定 |
| config.appid | string | APPID |
| config.ws | boolean | 連接地址前綴是否為ws/wss: true - 連接地址前綴為ws或wss, false - 連接地址前綴為http/https |
| config.autoLogin | boolean | 是否自動登入 |
| config.dnsServer | string | undefined | DNS伺服器地址, 可以不設定,預設為 https://dns.lanying.chat/v2/app_dns |
| config.logLevel | string | SDK的日誌等級, 預設為debug, 取值為 debug、info、warn、error 或 off, 其中off為不打印日誌。 |
Example
const config = {
// dnsServer: "https://dns.lanying.chat/v2/app_dns",
appid: "YOUR_APP_ID",
ws: false, // uniapp版需要設定為true, web版需要設定為false
autoLogin: true
};
import flooim from 'floo-3.0.0';
const im = flooim(config);
{% lanying_code_snippet repo="lanying-im-web",class="",function="flooim" %}{% endlanying_code_snippet %}flooim.login(opt)#
登入
Kind: static method of flooim
| Param | Type | Description |
|---|---|---|
| opt | object | |
| opt.name | string | 使用者名 |
| opt.password | string | 密碼 |
Example
{% lanying_code_snippet repo="lanying-im-web",class="im",function="login" %}{% endlanying_code_snippet %}
flooim.qrlogin(opt)#
二維碼登入
Kind: static method of flooim
| Param | Type | Description |
|---|---|---|
| opt | object | |
| opt.user_id | number | 使用者ID |
| opt.password | string | 密碼 |
Example
{% lanying_code_snippet repo="lanying-im-web",class="im",function="qrlogin" %}{% endlanying_code_snippet %}
flooim.tokenLogin(user_id, token)#
token登入
Kind: static method of flooim
| Param | Type | Description |
|---|---|---|
| user_id | number | 使用者ID |
| token | string | Token |
Example
{% lanying_code_snippet repo="lanying-im-web",class="im",function="tokenLogin" %}{% endlanying_code_snippet %}
flooim.idLogin(opt)#
使用使用者ID和密碼登入
Kind: static method of flooim
| Param | Type | Description |
|---|---|---|
| opt | object | |
| opt.user_id | number | 使用者ID |
| opt.password | string | 密碼 |
Example
{% lanying_code_snippet repo="lanying-im-web",class="im",function="idLogin" %}{% endlanying_code_snippet %}
flooim.isLogin() ⇒ boolean#
是否已登入
Kind: static method of flooim
Returns: boolean - 是否已登入
Example
{% lanying_code_snippet repo="lanying-im-web",class="im",function="isLogin" %}{% endlanying_code_snippet %}
flooim.on(options, ext)#
事件監聽
Kind: static method of flooim
| Param | Type | Description |
|---|---|---|
| options | Event | Object.<Event, EventCallback> | 可以為事件名,也可以為事件名和事件回呼 |
| ext | EventCallback | undefined | 事件回呼,只有options為事件名時需要設定 |
Example
const im = flooim(config);
im.on('event', (ret) => {
//do something with ret
})
// or
im.on({
eventName: (ret) => {
//do something with ret
},
...
})
{% lanying_code_snippet repo="lanying-im-web",class="im",function="on" %}{% endlanying_code_snippet %}
flooim.off(options, ext)#
取消監聽
Kind: static method of flooim
| Param | Type | Description |
|---|---|---|
| options | Event | Object.<Event, EventCallback> | 可以為事件名,也可以為事件名和事件回呼 |
| ext | EventCallback | undefined | 事件回呼,只有options為事件名時需要設定 |
Example
const im = flooim(config);
im.off('events', (ret) => {
//do something with ret
})
// or
im.off({
eventName: (ret) => {
//do something with ret
},
...
})
{% lanying_code_snippet repo="lanying-im-web",class="im",function="off" %}{% endlanying_code_snippet %}
flooim.logout()#
退出賬戶
Kind: static method of flooim
Example
{% lanying_code_snippet repo="lanying-im-web",class="im",function="logout" %}{% endlanying_code_snippet %}
flooim.setLogLevel(logLevel)#
設定日誌等級
Kind: static method of flooim
| Param | Type | Description |
|---|---|---|
| logLevel | string | SDK的日誌等級, 預設為debug, 取值為 debug、info、warn、error 或 off, 其中off為不打印日誌。 |
Example
{% lanying_code_snippet repo="lanying-im-web",class="im",function="setLogLevel" %}{% endlanying_code_snippet %}