# Invite

#### new Invite(fromUserId, toUserId, options-)

Description:

  - 邀请Invite构造函数。

##### Parameters:

Name | Type | Description
--- | --- | ---
`fromUserId` | String | 邀请发起方用户id
`toUserId` | String | 邀请接受方用户id
`options-` | Object | 参数

### Members

#### (readonly) InviteCallbackEnum :string

Description:

  - Invite级别回调的枚举

##### Properties:

Name | Type | Description
--- | --- | ---
`CALL_ACCEPT_NOTIFY` | string |
`CALL_REJECT_NOTIFY` | string |
`CALL_TIMEOUT_NOTIFY` | string |
`CALL_RINGING_NOTIFY` | string |
`CALL_CANCEL_NOTIFY` | string |
`RESPONSE_CALL_TIMEOUT_NOTIFY` | string |
`CALL_CLOSE_NOTIFY` | string |

Invite级别回调的枚举

##### Type:

- string

### Methods

#### accept(options,接受方发送的参数，也可以不填)

Description:

  - 接受邀请

##### Parameters:

Name | Type | Description
--- | --- | ---
`options,接受方发送的参数，也可以不填` | Object |

#### addCallback(type, callback)

Description:

  - 邀请级别的回调

##### Example

    invite.addCallback(Invite.InviteCallbackEnum.CALL_ACCEPT_NOTIFY, onCallAccept);
    invite.addCallback(Invite.InviteCallbackEnum.CALL_REJECT_NOTIFY, onCallReject);
    invite.addCallback(Invite.InviteCallbackEnum.CALL_TIMEOUT_NOTIFY, onCallTimeout);
    invite.addCallback(Invite.InviteCallbackEnum.CALL_RINGING_NOTIFY, onCallRinging);

    invite.addCallback(Invite.InviteCallbackEnum.CALL_CANCEL_NOTIFY, onCallCancel);
    invite.addCallback(Invite.InviteCallbackEnum.RESPONSE_CALL_TIMEOUT_NOTIFY, onResponseCallTimeout);

    invite.addCallback(Invite.InviteCallbackEnum.CALL_CLOSE_NOTIFY, onCallClose);
    邀请请求已被接受的回调
    param:toUserId － 邀请接收者用户ID
    param:options － 邀请参数，json对象
    function onCallAccept(toUserId,options){
    }

    邀请请求已被拒绝的回调
    param:toUserId － 邀请接收者用户ID
    param:reason － 拒绝原因
    function onCallReject(toUserId,reson){
    }

    邀请请求无响应，超时回调
    param:toUserId － 邀请接收者用户ID
    function onCallTimeout(toUserId){
    }

    邀请请求响铃回调
    param:toUserId － 邀请接收者用户ID
    function onCallRinging(toUserId){
    }

    邀请发启者取消邀请的回调
    param:fromUserId － 邀请发启用户ID
    function onCallCancel(fromUserId) {

    }

    接收邀请者无响应，超时回调
    param:fromUserId － 邀请发启用户ID
    function onResponseCallTimeout(fromUserId){

    }

    邀请关闭
    param:toUserId － 关闭发启用户ID
    param:reason － 关闭原因
    function onCallClose(fromUserId,reson){

    }

##### Parameters:

Name | Type | Description
--- | --- | ---
`type` | UserCallback | 回调枚举标识
`callback` | Object | 回调方法名,可以自定义

#### cancel()

Description:

  - 取消邀请

#### close(reson)

Description:

  - 关闭

##### Parameters:

Name | Type | Description
--- | --- | ---
`reson` |  | 关闭原因

#### reject(reson)

Description:

  - 拒绝邀请

##### Parameters:

Name | Type | Description
--- | --- | ---
`reson` | String | 拒绝原因

#### ringing()

Description:

  - 发送振铃