Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

_m_utils.js 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. if (!window.glob_mx){
  2. // window.glob_mx={}
  3. }
  4. function disp(o){
  5. APP.store.dispatch(o)
  6. }
  7. // default event handler this should match all events
  8. mhndlr_opt_null = {
  9. from: undefined,
  10. handler: "onAll",
  11. id: null,
  12. name: null,
  13. // "http://jitsi.org/jitmeet"
  14. ns: null,
  15. options: {matchBareFromJid: false, ignoreNamespaceFragment: false},
  16. type: null,
  17. user: true,
  18. cstr:"test"
  19. };
  20. mhndlr_opt_x = {
  21. cstr:"?",
  22. ns:"corner_mx",
  23. handler:mhndlr,
  24. }
  25. function add_handler_m(handler) {
  26. var phx = APP.connection.xmpp.connection._stropheConn.handlers[0].__proto__;
  27. var hxa=Object.create(phx)
  28. Object.assign(hxa,mhndlr_opt_null,handler)
  29. APP.connection.xmpp.connection._stropheConn.addHandlers.push(hxa)
  30. return hxa
  31. }
  32. function tmsgx(data,tag="div",attrs={}){
  33. // return
  34. // clog("tmsgx",{data,tag,attrs})
  35. var ns = {xmlns:"corner_mx"}
  36. var msg = $build("message",{ to: window.APP.conference._room.room.roomjid,
  37. type: 'groupchat',
  38. });
  39. var payload=JSON.stringify(data)
  40. Object.assign({},ns,attrs)
  41. msg.c(tag, payload,Object.assign({},ns,attrs)).up();
  42. // console.log("zzzz")
  43. APP.conference._room.room.connection.send(msg)
  44. }
  45. // "nl4qbyiz61z-mce1@specplot.com/FlUkwrLs"
  46. // "maf@conference.i.specplot.com/0695c1e4"
  47. function tmsgx2(data,opt_arg={},attrs={}){
  48. // return
  49. dflt_opt = {
  50. tag:"code",
  51. type:"chat",
  52. to:window.APP.conference._room.room.roomjid,
  53. }
  54. var opt = Object.assign({},dflt_opt,opt_arg)
  55. var ns = {xmlns:"corner_mx"}
  56. var msg = $build("message",{ to: opt.to,
  57. type: opt.type,
  58. });
  59. var payload=JSON.stringify(data)
  60. Object.assign({},ns,attrs)
  61. msg.c(opt.tag, payload,Object.assign({},ns,attrs)).up();
  62. // console.log("zzzz")
  63. APP.conference._room.room.connection.send(msg)
  64. }
  65. function tmsgx3(data,opt_arg={},attrs={}){
  66. // return
  67. // clog("tmsgx3",{data,opt_arg,attrs})
  68. dflt_opt = {
  69. tag:"code",
  70. // type:"chat",
  71. to:window.APP.conference._room.room.roomjid,
  72. }
  73. var opt = Object.assign({},dflt_opt,opt_arg)
  74. // clog("T:",data,opt,opt.type)
  75. if (!opt.type){
  76. // clog("NO TYPE")
  77. opt.to == dflt_opt.to ? opt.type = "groupchat" : opt.type = "chat"
  78. }
  79. // clog("T:",data,opt,opt.type)
  80. var ns = {xmlns:"corner_mx"}
  81. var msg = $build("message",{ to: opt.to,
  82. type: opt.type,
  83. // from: "nnnx@conference.jfidev.com/3db7bf15",
  84. // xtra: "nnnx@conference.jfidev.com/3db7bf15",
  85. });
  86. var payload
  87. if (typeof(data) == "string"){
  88. payload=data
  89. } else {
  90. payload=JSON.stringify(data)
  91. }
  92. Object.assign({},ns,attrs)
  93. msg.c(opt.tag, payload,Object.assign({},ns,attrs)).up();
  94. // console.log("zzzz")
  95. APP.conference._room.room.connection.send(msg)
  96. }
  97. function mhndlr_rld_dflt(a0,a1,a2,a3,a4){
  98. clog("mhndlr... dflt")
  99. return true
  100. }
  101. if (!window.mhndlr_rld){
  102. window.mhndlr_rld = mhndlr_rld_dflt
  103. }
  104. function mhndlr(a0,a1,a2,a3,a4){
  105. // clog("MH!")
  106. setTimeout(window.mhndlr_rld,1,this,a0,a1,a2,a3,a4)
  107. return true
  108. }
  109. function init_mx(){
  110. clog("INITMX")
  111. add_handler_m(mhndlr_opt_x)
  112. // add_handler_m(mhndlr_opt_x_all)
  113. }
  114. // init_mx will be called once we join th confrence
  115. if (window.ifn_obj){
  116. ifn_obj.init_conf_join.push(init_mx)
  117. }