rtcsdk.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. document.addEventListener( "plusready", function()
  2. {
  3. var _BARCODE = 'rtcplugin',
  4. B = window.plus.bridge;
  5. var rtcplugin =
  6. {
  7. init : function (eventCallback)
  8. {
  9. var success = typeof eventCallback !== 'function' ? null : function(args)
  10. {
  11. eventCallback(args);
  12. };
  13. var fail = function(code)
  14. {
  15. alert(code);
  16. };
  17. var callbackID = B.callbackId(success, fail);
  18. return B.exec(_BARCODE, "init", [callbackID]);
  19. },
  20. login : function (ip, port, userid, password)
  21. {
  22. return B.execSync(_BARCODE, "login", [ip, port, userid, password]);
  23. },
  24. logout : function ()
  25. {
  26. return B.execSync(_BARCODE, "logout");
  27. },
  28. inOnline : function ()
  29. {
  30. return B.execSync(_BARCODE, "inOnline");
  31. },
  32. makeCall : function (peerUserId)
  33. {
  34. return B.execSync(_BARCODE, "makeCall", [peerUserId]);
  35. }
  36. };
  37. window.plus.rtcplugin = rtcplugin;
  38. init(onCallback);
  39. login('121.40.189.42', '8080', 'patient', '');
  40. }, true );
  41. function init(eventCallback)
  42. {
  43. var ret = plus.rtcplugin.init(eventCallback);
  44. if (ret == "false") {
  45. alert("初始化音视频库失败!");
  46. }
  47. }
  48. function login(ip, port, userid, password)
  49. {
  50. var ret = plus.rtcplugin.login(ip, port, userid, password);
  51. if (ret == "false") {
  52. //alert("调用登录接口失败!");
  53. }
  54. }
  55. function logout()
  56. {
  57. var ret = plus.rtcplugin.logout();
  58. if (ret == "false") {
  59. alert("调用注销接口失败!");
  60. }
  61. }
  62. function inOnline()
  63. {
  64. return plus.rtcplugin.inOnline();
  65. }
  66. function makeCall(peerUserId)
  67. {
  68. var ret = plus.rtcplugin.makeCall(peerUserId);
  69. if (ret == "false") {
  70. alert("调用呼叫接口失败!");
  71. }
  72. }
  73. function onCallback(result) {
  74. var event = result[0];
  75. if (event == "onlogin") {
  76. //alert('登录成功');
  77. }
  78. else if (event == "onlogout") {
  79. //alert('进入候诊室失败,请检查网络!');
  80. }
  81. };