Unverified Commit 9ef2be3f authored by Murtaza Patrawala's avatar Murtaza Patrawala Committed by GitHub
Browse files

Merge pull request #144 from dhruvjain99/handle-decline-call-status

[NEW] Support Video and Audio calling in Livechat
parents e387b2f4 b19147cc
......@@ -40,6 +40,7 @@ export default class ApiLivechat extends ApiBase {
}
async deleteVisitor () { return (await this.del(`livechat/visitor/${this.credentials.token}`)).visitor }
async updateVisitorStatus (status: string) { return (await this.post(`livechat/visitor.status`, { token: this.credentials.token, status })).status }
async updateCallStatus (callStatus: string, rid: string, callId: string) { return (await this.post(`livechat/visitor.callStatus`, { token: this.credentials.token, callStatus, rid, callId })).callStatus }
async nextAgent (department: string = '') { return (await this.get(`livechat/agent.next/${this.credentials.token}`, { department })).agent }
async agent ({ rid }: any) { return (await this.get(`livechat/agent.info/${rid}/${this.credentials.token}`)).agent }
async message (id: string, params: ILivechatRoom) { return (await this.get(`livechat/message/${id}`, { token: this.credentials.token, ...params })).message }
......
......@@ -83,6 +83,10 @@ export default class LivechatClient extends LivechatRest implements ISocket {
return (await this.socket as IDriver).notifyVisitorTyping(rid, username, typing, this.credentials.token)
}
async notifyCallDeclined (rid: string) {
return (await this.socket as IDriver).notifyCallDeclined(rid)
}
async subscribe (topic: string, eventName: string) {
const { token } = this.credentials
return (await this.socket as ISocket).subscribe(topic, eventName, { token, visitorToken: token })
......
......@@ -584,6 +584,10 @@ export class DDPDriver extends EventEmitter implements ISocket, IDriver {
return this.ddp.call('stream-notify-room', `${ rid }/typing`, username, typing, { token })
}
notifyCallDeclined = (rid: string) => {
return this.ddp.call('stream-notify-room', `${ rid }/webrtc`, 'callStatus', { callStatus: 'declined' })
}
ejsonMessage = (message: any) => {
if (message.ts) {
message.ts = new Date(message.ts.$date)
......
......@@ -50,6 +50,8 @@ export interface IDriver {
onTyping (cb: ICallback): Promise<any>
notifyVisitorTyping (rid: string, username: string, typing: boolean, token: string): Promise<any>
notifyCallDeclined (rid: string): Promise<any>
methodCall (method: string, ...args: any[]): Promise<any>
}
......
......@@ -123,6 +123,10 @@ export class MQTTDriver extends EventEmitter implements ISocket, IDriver {
return Promise.resolve() as any
}
notifyCallDeclined (rid: string): Promise<any> {
return Promise.resolve() as any
}
onStreamData (name: string, cb: ICallback): Promise<any> {
return Promise.resolve(this.on(name, ({ fields: { args: [message] } }: any) => cb((message)))) as any
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment