,
56 | "message": ""
57 | }
58 | }
59 | ```
60 |
61 | The placeholders for an error will contain the following values:
62 |
63 | * `request-id`: the same identifier received in the JSON-RPC request
64 | * `code`: an integer indicated the code of the error
65 | * `reason`: a string containing the reason of the error
66 |
67 | If, however, the command invocation was successful, the Call API engine will
68 | start to generate JSON-RPC notifications about the progress of the command.
69 | These notifications look like this:
70 |
71 | ```
72 | "jsonrpc": "2.0"
73 | "method": "",
74 | "params": {
75 | "cmd_id": "",
76 | "event": "",
77 | "data": "",
78 | }
79 | ```
80 |
81 | A notification will contain the following values as placeholders:
82 |
83 | * `command`: the command that triggered this notification
84 | * `cmd-id`: the id of the command, as provided in the initial JSON-RPC
85 | response
86 | * `event`: one of the following values:
87 | * `Error`: indicates an error has been triggered
88 | * `Ended`: indicates that the command has been completed
89 | * an arbitrary name describing the status of the execution
90 | * `data`: optional JSON node, containing extra information about the error, or
91 | the progress of the command being executed; note that the `Ended` event
92 | does not have a `data` node.
93 |
94 | # Commands
95 |
96 | ## CallStart
97 |
98 | ### Parameters
99 |
100 | * _"caller"_ (string, mandatory)
101 | * _"callee"_ (string, mandatory)
102 |
103 | ### Events
104 |
105 | * _CallerAnswered_: triggered when the caller answered the initial call
106 | * _caller_: the caller that has just answered the call
107 | * _callee_: the callee that is being reached next
108 | * _Transferring_: triggered when the caller is trying to reach the callee
109 | * _caller_: the caller of the new call
110 | * _destination_: the SIP URI that is being called
111 | * _TransferStart_: triggered when the caller starts the call to callee
112 | * _callid_: the Call-ID of the new call
113 | * _caller_: the caller of the new call
114 | * _callee_: the callee that is being called
115 | * _TransferPending_: _optional_, contains extra information provided by the UAC
116 | regarding the new call
117 | * _callid_: the Call-ID of the new call
118 | * _caller_: the caller of the new call
119 | * _callee_: the callee of the new call
120 | * _extra_: _optional_, extra information provided by the caller
121 | * _CalleeAnswered_: triggered when the callee answers the call
122 | * _callid_: the Call-ID of the new call
123 | * _caller_: the caller of the new call
124 | * _callee_: the callee of the new call
125 |
126 | ### Example JSON-RPC flow:
127 |
128 | ```
129 | 1) WS client ----------> API
130 |
131 | {
132 | "method": "CallStart",
133 | "params": {
134 | "caller": "sip:alice@10.0.0.10",
135 | "callee": "sip:bob@10.0.0.11"
136 | },
137 | "id": "831717ed97e5",
138 | "jsonrpc": "2.0"
139 | }
140 |
141 | 2) WS client <---------- API
142 |
143 | {
144 | "result": {
145 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178",
146 | "status": "Started"
147 | },
148 | "id": "831717ed97e5",
149 | "jsonrpc": "2.0"
150 | }
151 |
152 | 3) WS client <---------- API
153 |
154 | {
155 | "method": "CallStart",
156 | "params": {
157 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178",
158 | "status": "CallerAnswered"
159 | "data": {
160 | "caller": "sip:alice@10.0.0.10",
161 | "callee": "sip:bob@10.0.0.11"
162 | }
163 | },
164 | "jsonrpc": "2.0"
165 | }
166 |
167 | 4) WS client <---------- API
168 |
169 | {
170 | "method": "CallStart",
171 | "params": {
172 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178",
173 | "status": "Transferring"
174 | "data": {
175 | "caller": "sip:alice@10.0.0.10",
176 | "callee": "sip:bob@10.0.0.11"
177 | }
178 | },
179 | "jsonrpc": "2.0"
180 | }
181 |
182 | 5) WS client <---------- API
183 |
184 | {
185 | "method": "CallStart",
186 | "params": {
187 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178",
188 | "status": "TransferStart"
189 | "data": {
190 | "callid": "1fc8043a-3f89-49f9-8f8c-4c284faf69e3",
191 | "caller": "sip:alice@10.0.0.10",
192 | "callee": "sip:bob@10.0.0.11"
193 | }
194 | },
195 | "jsonrpc": "2.0"
196 | }
197 |
198 | 6) WS client <---------- API
199 |
200 | {
201 | "method": "CallStart",
202 | "params": {
203 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178",
204 | "status": "TransferPending"
205 | "data": {
206 | "callid": "1fc8043a-3f89-49f9-8f8c-4c284faf69e3",
207 | "caller": "sip:alice@10.0.0.10",
208 | "callee": "sip:bob@10.0.0.11",
209 | "extra":"100 Trying"
210 | }
211 | },
212 | "jsonrpc": "2.0"
213 | }
214 |
215 | 7) WS client <---------- API
216 |
217 | {
218 | "method": "CallStart",
219 | "params": {
220 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178",
221 | "status": "CalleeAnswered"
222 | "data": {
223 | "callid": "1fc8043a-3f89-49f9-8f8c-4c284faf69e3",
224 | "caller": "sip:alice@10.0.0.10",
225 | "callee": "sip:bob@10.0.0.11"
226 | }
227 | },
228 | "jsonrpc": "2.0"
229 | }
230 |
231 | 8) WS client <---------- API
232 |
233 | {
234 | "method": "CallStart",
235 | "params": {
236 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178"
237 | "status": "Ended"
238 | },
239 | "jsonrpc": "2.0"
240 | }
241 | ```
242 |
243 | ## CallBlindTransfer
244 |
245 | ### Parameters
246 |
247 | * _"callid"_ (string, mandatory) - the SIP Call-ID of the targeted dialog
248 | * _"leg"_ (string, mandatory) - which party to transfer. Possible values: _"caller"_, _"callee"_
249 | * _"destination"_ (string, mandatory) - SIP URI of the blind transfer target
250 |
251 | ### Events
252 |
253 | * _Transferring_: triggered when the transferrer has accepted the transfer
254 | * _destination_: the destination URI specified in the request
255 | * _TransferStart_: triggered when the leg starts the call the new destination
256 | * _callid_: the Call-ID of the new call
257 | * _destination_: SIP URI of the party that we are transferring to - note
258 | that the URI might be altered after the lookup has been performed
259 | * _TransferPending_: _optional_, triggered when the participant starts the
260 | transferring call
261 | * _callid_: the Call-ID of the new call
262 | * _destination_: SIP URI of the party that we are transferring to
263 | * _extra_: _optional_, extra information provided by the transferrer
264 | * _TransferSuccessful_: triggered when the destination accepted the new call
265 | * _callid_: the Call-ID of the new call
266 | * _destination_: SIP URI of the party that we are transferring to
267 |
268 | ### Example JSON-RPC flow:
269 |
270 | ```
271 | # 1) WS client ----------> API
272 |
273 | {
274 | "method": "CallBlindTransfer",
275 | "params": {
276 | "callid": "431fc357.a3e3.49c2@127.0.0.1",
277 | "leg": "callee",
278 | "destination": "sip:cindy@10.0.0.11"
279 | },
280 | "id": "831717ed97e5",
281 | "jsonrpc": "2.0"
282 | }
283 |
284 | # 2) WS client <---------- API
285 |
286 | {
287 | "result": {
288 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178",
289 | "status": "Started"
290 | },
291 | "id": "831717ed97e5",
292 | "jsonrpc": "2.0"
293 | }
294 |
295 | # 3) WS client <---------- API
296 |
297 | {
298 | "method": "CallBlindTransfer",
299 | "params": {
300 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178",
301 | "event": "Transferring",
302 | "data": {
303 | "destination": "sip:cindy@10.0.0.11"
304 | }
305 | },
306 | "jsonrpc": "2.0"
307 | }
308 |
309 | # 4) WS client <---------- API
310 |
311 | {
312 | "method": "CallBlindTransfer",
313 | "params": {
314 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178",
315 | "event": "TransferStart"
316 | "data": {
317 | "callid": "29ad6fdb-7806-4c17-b235-02b8f9fad1ae",
318 | "destination": "sip:cindy@10.0.0.11"
319 | }
320 | },
321 | "jsonrpc": "2.0"
322 | }
323 |
324 | # 5) WS client <---------- API
325 |
326 | {
327 | "method": "CallBlindTransfer",
328 | "params": {
329 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178",
330 | "event": "TransferSuccessful"
331 | "data": {
332 | "callid": "29ad6fdb-7806-4c17-b235-02b8f9fad1ae",
333 | "destination": "sip:cindy@10.0.0.11"
334 | }
335 | },
336 | "jsonrpc": "2.0"
337 | }
338 |
339 | # 6) WS client <---------- API
340 |
341 | {
342 | "method": "CallBlindTransfer",
343 | "params": {
344 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178"
345 | "event": "Ended"
346 | },
347 | "jsonrpc": "2.0"
348 | }
349 | ```
350 |
351 | ## CallAttendedTransfer
352 |
353 | ### Parameters
354 |
355 | * _"callidA"_ (string, mandatory) - the SIP Call-ID of the dialog #1
356 | * _"legA"_ (string, mandatory) - which party to transfer from dialog #1. Possible values: _"caller"_, _"callee"_
357 | * _"callidB"_ (string, mandatory) - the SIP Call-ID of the dialog #2
358 | * _"legB"_ (string, mandatory) - which party to transfer from dialog #2. Possible values: _"caller"_, _"callee"_
359 |
360 | ### Events
361 |
362 | * _Transferring_: triggered when the transferrer has accepted the transfer
363 | * _TransferStart_: triggered when the transferring leg of Call-ID of the
364 | dialog #1 is calling the leg in dialog #2
365 | * _callid_: the Call-ID of the new call
366 | * _destination_: SIP URI of the party that we are transferring to
367 | * _TransferPending_: _optional_, triggered when the participant starts the
368 | transferring call
369 | * _callid_: the Call-ID of the new call
370 | * _destination_: SIP URI of the party that we are transferring to
371 | * _extra_: _optional_, extra information provided by the transferrer
372 | * _TransferSuccessful_: triggered when the destination accepted the new call
373 | * _callid_: the Call-ID of the new call
374 | * _destination_: SIP URI of the party that we are transferring to
375 |
376 | ### Example JSON-RPC flow:
377 |
378 | ```
379 | # 1) WS client ----------> API
380 |
381 | {
382 | "method": "CallAttendedTransfer",
383 | "params": {
384 | "callidA": "431fc357.a3e3.49c2@127.0.0.1",
385 | "legA": "caller",
386 | "callidB": "0ba2cf53-9a78-41de-8fe6-f2e5bb4d1a1e",
387 | "legB": "callee",
388 | }
389 |
390 | "id": "831717ed97e5",
391 | "jsonrpc": "2.0"
392 | }
393 |
394 | # 2) WS client <---------- API
395 |
396 | {
397 | "result": {
398 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178",
399 | "status": "Started"
400 | }
401 |
402 | "id": "831717ed97e5",
403 | "jsonrpc": "2.0"
404 | }
405 |
406 | # 3) WS client <---------- API
407 |
408 | {
409 | "method": "CallAttendedTransfer",
410 | "params": {
411 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178",
412 | "event": "Transferring"
413 | },
414 | "jsonrpc": "2.0"
415 | }
416 |
417 | # 4) WS client <---------- API
418 |
419 | {
420 | "method": "CallAttendedTransfer",
421 | "params": {
422 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178",
423 | "event": "TransferStart"
424 | "data": {
425 | "callid": "29ad6fdb-7806-4c17-b235-02b8f9fad1ae",
426 | "destination": "sip:cindy@10.0.0.11"
427 | }
428 | },
429 | "jsonrpc": "2.0"
430 | }
431 |
432 | # 5) WS client <---------- API
433 |
434 | {
435 | "method": "CallAttendedTransfer",
436 | "params": {
437 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178",
438 | "event": "TransferSuccessful"
439 | "data": {
440 | "callid": "29ad6fdb-7806-4c17-b235-02b8f9fad1ae",
441 | "destination": "sip:cindy@10.0.0.11"
442 | }
443 | },
444 | "jsonrpc": "2.0"
445 | }
446 |
447 | # 6) WS client <---------- API
448 |
449 | {
450 | "method": "CallAttendedTransfer",
451 | "params": {
452 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178"
453 | "event": "Ended"
454 | },
455 | "jsonrpc": "2.0"
456 | }
457 | ```
458 |
459 | ## CallHold
460 |
461 | ### Parameters
462 |
463 | * _"callid"_ (string, mandatory) - the SIP Call-ID of the target dialog
464 |
465 | ### Events
466 |
467 | * _CallHolding_: triggered when the command was received by the proxy
468 | * _CallHoldStart_: triggered when the proxy sends a hold INVITE to one of the
469 | legs
470 | * _leg_: the call's leg that the message is being sent to (_caller_ or
471 | _callee_)
472 | * _CallHoldSuccessful_: triggered when one of the legs successfully accepted
473 | the call hold
474 | * _leg_: the call's leg that completed the call hold (_caller_ or _callee_)
475 |
476 | ### Example JSON-RPC flow:
477 |
478 | ```
479 | # 1) WS client ----------> API
480 |
481 | {
482 | "method": "CallHold",
483 | "params": {
484 | "callid": "431fc357.a3e3.49c2@127.0.0.1",
485 | },
486 | "id": "831717ed97e5",
487 | "jsonrpc": "2.0"
488 | }
489 |
490 | # 2) WS client <---------- API
491 |
492 | {
493 | "result": {
494 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178",
495 | "status": "Started"
496 | },
497 | "id": "831717ed97e5",
498 | "jsonrpc": "2.0"
499 | }
500 |
501 | # 3) WS client <---------- API
502 |
503 | {
504 | "method": "CallHold",
505 | "params": {
506 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178",
507 | "event": "CallHolding"
508 | },
509 | "jsonrpc": "2.0"
510 | }
511 |
512 | # 4) WS client <---------- API
513 |
514 | {
515 | "method": "CallHold",
516 | "params": {
517 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178",
518 | "event": "CallHoldStart",
519 | "data": {
520 | "leg": "caller"
521 | },
522 | },
523 | "jsonrpc": "2.0"
524 | }
525 |
526 | # 5) WS client <---------- API
527 |
528 | {
529 | "method": "CallHold",
530 | "params": {
531 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178",
532 | "event": "CallHoldStart"
533 | "data": {
534 | "leg": "callee"
535 | },
536 | },
537 | "jsonrpc": "2.0"
538 | }
539 |
540 | # 6) WS client <---------- API
541 |
542 | {
543 | "method": "CallHold",
544 | "params": {
545 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178",
546 | "event": "CallHoldSuccessful"
547 | "data": {
548 | "leg": "caller"
549 | },
550 | },
551 | "jsonrpc": "2.0"
552 | }
553 |
554 | # 7) WS client <---------- API
555 |
556 | {
557 | "method": "CallHold",
558 | "params": {
559 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178",
560 | "event": "CallHoldSuccessful"
561 | "data": {
562 | "leg": "callee"
563 | },
564 | },
565 | "jsonrpc": "2.0"
566 | }
567 |
568 | # 8) WS client <---------- API
569 |
570 | {
571 | "method": "CallHold",
572 | "params": {
573 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178",
574 | "event": "Ended"
575 | },
576 | "jsonrpc": "2.0"
577 | }
578 | ```
579 |
580 | ## CallUnhold
581 |
582 | ### Parameters
583 |
584 | * _"callid"_ (string, mandatory) - the SIP Call-ID of the target dialog
585 |
586 | ### Events
587 |
588 | * _CallUnholding_: triggered when the command was received by the proxy
589 | * _CallUnholdStart_: triggered when the proxy sends a hold INVITE to one of the
590 | legs
591 | * _leg_: the call's leg that the message is being sent to (_caller_ or
592 | _callee_)
593 | * _CallUnholdSuccessful_: triggered when one of the legs successfully resumes
594 | * _leg_: the call's leg that resumed the call (_caller_ or _callee_)
595 |
596 | ### Example JSON-RPC flow:
597 |
598 | ```
599 | # 1) WS client ----------> API
600 |
601 | {
602 | "method": "CallUnhold",
603 | "params": {
604 | "callid": "431fc357.a3e3.49c2@127.0.0.1",
605 | },
606 | "id": "831717ed97e5",
607 | "jsonrpc": "2.0"
608 | }
609 |
610 | # 2) WS client <---------- API
611 |
612 | {
613 | "result": {
614 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178",
615 | "status": "Started"
616 | },
617 | "id": "831717ed97e5",
618 | "jsonrpc": "2.0"
619 | }
620 |
621 | # 3) WS client <---------- API
622 |
623 | {
624 | "method": "CallUnhold",
625 | "params": {
626 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178",
627 | "event": "CallUnholding"
628 | },
629 | "jsonrpc": "2.0"
630 | }
631 |
632 | # 4) WS client <---------- API
633 |
634 | {
635 | "method": "CallUnhold",
636 | "params": {
637 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178",
638 | "event": "CallUnholdStart",
639 | "data": {
640 | "leg": "caller"
641 | },
642 | },
643 | "jsonrpc": "2.0"
644 | }
645 |
646 | # 5) WS client <---------- API
647 |
648 | {
649 | "method": "CallUnhold",
650 | "params": {
651 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178",
652 | "event": "CallUnholdStart"
653 | "data": {
654 | "leg": "callee"
655 | },
656 | },
657 | "jsonrpc": "2.0"
658 | }
659 |
660 | # 6) WS client <---------- API
661 |
662 | {
663 | "method": "CallUnhold",
664 | "params": {
665 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178",
666 | "event": "CallUnholdSuccessful"
667 | "data": {
668 | "leg": "caller"
669 | },
670 | },
671 | "jsonrpc": "2.0"
672 | }
673 |
674 | # 7) WS client <---------- API
675 |
676 | {
677 | "method": "CallUnhold",
678 | "params": {
679 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178",
680 | "event": "CallUnholdSuccessful"
681 | "data": {
682 | "leg": "callee"
683 | },
684 | },
685 | "jsonrpc": "2.0"
686 | }
687 |
688 | # 8) WS client <---------- API
689 |
690 | {
691 | "method": "CallUnhold",
692 | "params": {
693 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178",
694 | "event": "Ended"
695 | },
696 | "jsonrpc": "2.0"
697 | }
698 | ```
699 |
700 | ## CallEnd
701 |
702 | ### Parameters
703 |
704 | * _"callid"_ (string, mandatory) - the SIP Call-ID of the target dialog
705 |
706 | ### Events
707 |
708 | *NO events*
709 |
710 | ### Example JSON-RPC flow:
711 |
712 | ```
713 | # 1) WS client ----------> API
714 |
715 | {
716 | "method": "CallEnd",
717 | "params": {
718 | "callid": "431fc357.a3e3.49c2@127.0.0.1"
719 | },
720 | "id": "831717ed97e5",
721 | "jsonrpc": "2.0"
722 | }
723 |
724 | # 2) WS client <---------- API
725 |
726 | {
727 | "result": {
728 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178",
729 | "status": "Started"
730 | },
731 | "id": "831717ed97e5",
732 | "jsonrpc": "2.0"
733 | }
734 |
735 | # 3) WS client <---------- API
736 |
737 | {
738 | "method": "CallEnd",
739 | "params": {
740 | "cmd_id": "b8179f1e-b4e4-4ac7-9990-4bf64f084178",
741 | "event": "Ended"
742 | }
743 | "jsonrpc": "2.0"
744 | }
745 | ```
746 |
747 | ## Echo
748 |
749 | Command that receives arbitrary parameters and outputs them back as a
750 | notification. This command is useful to test connectivity to the API server.
751 |
752 | ### Parameters
753 |
754 | _Any_ parameter
755 |
756 | ### Events
757 |
758 | * _Reply_: contains a JSON object with the same JSON as specified in the request.
759 |
760 | ### Example JSON-RPC flow:
761 |
762 | ```
763 | 1) WS client ----------> API
764 |
765 | {
766 | "method": "Echo",
767 | "params": {
768 | "test": "echo",
769 | },
770 | "id": "33f6c98c821b",
771 | "jsonrpc": "2.0"
772 | }
773 |
774 | 2) WS client <---------- API
775 |
776 | {
777 | "result": {
778 | "cmd_id": "0f8a1664-01e2-46fe-ae55-e02715afee02",
779 | "event": "Started"
780 | },
781 | "id": "33f6c98c821b",
782 | "jsonrpc": "2.0"
783 | }
784 |
785 | 3) WS client <---------- API
786 |
787 | {
788 | "method": "Echo",
789 | "params": {
790 | "cmd_id": "0f8a1664-01e2-46fe-ae55-e02715afee02",
791 | "event": "Reply",
792 | "data": {"test":"echo"}
793 | },
794 | "jsonrpc": "2.0"
795 | }
796 |
797 | 4) WS client <---------- API
798 |
799 | {
800 | "method": "Echo",
801 | "params": {
802 | "cmd_id": "0f8a1664-01e2-46fe-ae55-e02715afee02",
803 | "event": "Ended"
804 | },
805 | "jsonrpc": "2.0"
806 | }
807 | ```
808 |
--------------------------------------------------------------------------------
/docs/README.md:
--------------------------------------------------------------------------------
1 | This page contains the documentation of the Call API project, split in
2 | multiple pages:
3 |
4 | * **[Commands](Commands.md)** - commands accepted by the **Call API** engine
5 |
--------------------------------------------------------------------------------
/examples/javascript/call-api.js:
--------------------------------------------------------------------------------
1 | var callApiURL = "ws://127.0.0.1:5059/call-api";
2 |
3 | var client = new $.JsonRpcClient({socketUrl: callApiURL, onmessage: CallOnMessage });
4 |
5 | var callid = null;
6 | var onHold = false;
7 |
8 | function CallStart() {
9 | var caller = document.getElementById("caller").value;
10 | var callee = document.getElementById("callee").value;
11 |
12 | $('#callModal').on('hidden.bs.modal', function () {
13 | if (callid)
14 | CallEnd();
15 | });
16 | toastr.info("Starting Call to " + caller);
17 |
18 | client.call("CallStart", { caller: caller, callee: callee},
19 | function(result) {
20 | toastr.info("Call initiated to caller");
21 | $('#callModal').find('.modal-title').text("Calling to " + caller);
22 | $('#caller-out').text(caller);
23 | $('#callee-out').text(callee);
24 | }, toastr.error);
25 | }
26 |
27 | function CallHold() {
28 | if (!callid) {
29 | toastr.error("Unknown call");
30 | return;
31 | }
32 | if (!onHold) {
33 | client.call("CallHold", { callid: callid },
34 | function(result) {
35 | toastr.info("Call on hold");
36 | $('#callModal').find('.modal-title').text("Call on hold")
37 | $('#callHold').addClass("active");
38 | $("#callHold").prop('aria-pressed', true)
39 | onHold = true;
40 | }, toastr.error);
41 | } else {
42 | client.call("CallUnhold", { callid: callid },
43 | function(result) {
44 | toastr.info("Call resumed");
45 | $('#callModal').find('.modal-title').text("Call resumed")
46 | $('#callHold').removeClass("active");
47 | $("#callHold").prop('aria-pressed', false)
48 | onHold = false;
49 | }, toastr.error);
50 | }
51 | }
52 |
53 | function CallEnd() {
54 | if (!callid) {
55 | toastr.error("Unknown call");
56 | return;
57 | }
58 | client.call("CallEnd", { callid: callid},
59 | function(result) {
60 | toastr.error("Call Ended");
61 | $('#callHold').addClass("invisible");
62 | $('#callEnd').addClass("invisible");
63 | $('#callid').text("");
64 | $('#callModal').modal('hide');
65 | callid = null;
66 | onHold = false;
67 | }, toastr.error);
68 | }
69 |
70 | function CallOnMessage(message) {
71 | var obj = JSON.parse(message.data);
72 | switch(obj.params.event) {
73 | case "Error":
74 | toastr.error(obj.params.data);
75 | $('#callModal').modal('hide');
76 | break;
77 | case "CallerAnswered":
78 | toastr.info("Caller Answered");
79 | $('#callModal').find('.modal-title').text(obj.params.data.caller + " answered");
80 | break;
81 | case "TransferStart":
82 | toastr.info("Calling Callee");
83 | $('#callModal').find('.modal-title').text("Calling to " + obj.params.data.callee);
84 | callid = obj.params.data.callid;
85 | $('#callid').text(callid);
86 | break;
87 | case "TransferPending":
88 | toastr.info("Callee status: " + obj.params.data.extra);
89 | break;
90 | case "Transferring":
91 | toastr.info("Transferring");
92 | break;
93 | case "CalleeAnswered":
94 | toastr.success("Callee Answered");
95 | $('#callModal').find('.modal-title').text("Ongoing call");
96 | $('#callHold').removeClass("invisible");
97 | $('#callEnd').removeClass("invisible");
98 | break;
99 | case "CallHolding":
100 | case "CallUnholding":
101 | case "CallHoldStart":
102 | case "CallUnholdStart":
103 | case "CallHoldSuccessful":
104 | case "CallUnholdSuccessful":
105 | case "Ended":
106 | break;
107 | default:
108 | toastr.warning("Unhandled message: " + obj.params.data);
109 | console.log(obj.params);
110 | break;
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/examples/javascript/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | Call API Javascript Example
16 |
17 |
18 |
19 | Start Call
20 |
21 |
22 | Caller
23 |
24 |
26 |
27 |
28 |
29 | Callee
30 |
31 |
33 |
34 |
35 |
37 |
38 |
39 |
40 |
41 |
42 |
67 |
65 |
66 |
68 |
69 |
70 |
71 |
72 |