You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

coninc.js 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. window.glob_dev_fns.conInc_render_icon = function (o,name,a3) {
  2. // body...
  3. // that.props.connectionStatus == "inactive"
  4. // clog("coninc render",o,name,a3)
  5. // clog("coninc render",o.that.props.connectionStatus,o.that.props.participantId,o,name)
  6. }
  7. function pleft(o){
  8. // clog("pleft",o,get_participants())
  9. discard_participant(o)
  10. discard_smallvid(o.action.participant.id)
  11. // clog("pleft",o,get_participants(),Object.keys(msto.participants) )
  12. // prune_smallvids()
  13. }
  14. function pjoin(o){
  15. add_participant(o)
  16. clog("pjoin",o,get_participants())
  17. }
  18. function deep_prop_v2(o,p){
  19. try {
  20. var arr = jc(p)
  21. var ret = o
  22. var retm = {}
  23. var key
  24. retm.arr = arr
  25. retm.arr0 = p
  26. while (arr.length){
  27. // clog("deep_prop",arr,ret)
  28. key = arr.shift()
  29. if (!arr.length){
  30. retm.v_exist = key in ret
  31. }
  32. ret = ret[key]
  33. retm.v = ret
  34. }
  35. // clog("deep_prop ret",ret)
  36. // return retm
  37. } catch(err){
  38. retm.err=err
  39. retm.key=key
  40. // console.error("DEEP_PROP ERR:",err)
  41. }
  42. return retm
  43. }
  44. function smallvid_filter_0(elm){
  45. var s = this
  46. // clog("smallvids filter",this,[...arguments])
  47. // clog("smallvids filter",s == "ID",s+"" == "ID",this,[...arguments])
  48. // clog("GLVCB",this,[...arguments])
  49. try{
  50. // return elm.isLocal
  51. return elm.id != this
  52. } catch{}
  53. }
  54. function discard_smallvid(id){
  55. var smallvids = glob_dev_hooks.smallvids.filter(smallvid_filter_0,id)
  56. glob_dev_hooks.smallvids = smallvids
  57. }
  58. function smallvid_filter(elm){
  59. // var s = this
  60. // clog("~",elm,elm.id)
  61. // clog("smallvids filter",this,[...arguments])
  62. // clog("smallvids filter",s == "ID",s+"" == "ID",this,[...arguments])
  63. // clog("GLVCB",this,[...arguments])
  64. try{
  65. // return elm.isLocal
  66. // return elm.id != this
  67. return this.includes(elm.id)
  68. } catch{}
  69. }
  70. function get_ids(){
  71. // clog("")
  72. var ret = []
  73. var p = get_participants()
  74. for (k of p){
  75. ret.push(k.id)
  76. // clog("~",k)
  77. }
  78. return ret
  79. // clog("~2",ret)
  80. }
  81. function prune_smallvids(){
  82. // var smallvids = get_participants().filter(smallvid_filter,Object.keys(msto.participants))
  83. var smallvids = glob_dev_hooks.smallvids.filter(smallvid_filter,get_ids())
  84. // clog(smallvids,glob_dev_hooks.smallvids)
  85. glob_dev_hooks.smallvids = smallvids
  86. }
  87. // function
  88. function coninc_conection_event(o){
  89. // clog("PARTICIPANT_UPDATED",o,get_participants())
  90. // "action.participant.connectionStatus".split(".")
  91. // clog("PARTICIPANT_UPDATED",o,get_participants())
  92. if (o.action && o.action.participant && o.action.participant.connectionStatus){
  93. }
  94. var ret = deep_prop_v2(o,"action.participant.connectionStatus".split("."))
  95. if (ret.v_exist){
  96. clog("conic +",ret,o)
  97. } else {
  98. clog("conic !",ret,o)
  99. // clog(ret)
  100. }
  101. // clog("PARTICIPANT_UPDATED",o)
  102. }
  103. function discard_participant(o){
  104. // o.action.participant.id
  105. delete window.glob_mx.participants[o.action.participant.id]
  106. }
  107. function add_participant(o){
  108. // o.action.participant.id
  109. if (o.action.participant.id == undefined || o.action.participant.id == "local"){
  110. return
  111. }
  112. window.glob_mx.participants[o.action.participant.id] = undefined
  113. }
  114. function conf_joined(){
  115. clog("conf_joined",{participants:get_participants(),smallvids:glob_dev_hooks.smallvids})
  116. }
  117. function init_participants_obj(){
  118. var i,k,j,v
  119. var sf,pf,merged,participants
  120. merged = {}
  121. var participants = participants_info()
  122. for ([k,v] of Object.entries(participants.sf)){
  123. merged[k]=v["_connectionStatus"] || participants.pf[k].connectionStatus
  124. // m2.push(v)
  125. // m2.push(k)
  126. }
  127. Object.assign(window.glob_mx.participants,merged)
  128. return {merged,participants}
  129. }
  130. // PARTICIPANT_JOINED
  131. // PARTICIPANT_LEFT
  132. // glob_mx.qxi_cb
  133. window.glob_mx.qxi_cb.PARTICIPANT_UPDATED = window.glob_mx.qxi_cb.PARTICIPANT_UPDATED || {}
  134. window.glob_mx.participants = window.glob_mx.participants || {}
  135. window.glob_mx.qxi_cb.PARTICIPANT_LEFT = window.glob_mx.qxi_cb.PARTICIPANT_LEFT || {}
  136. window.glob_mx.qxi_cb.CONFERENCE_JOINED = window.glob_mx.qxi_cb.CONFERENCE_JOINED || {}
  137. window.glob_mx.qxi_cb.PARTICIPANT_JOINED = window.glob_mx.qxi_cb.PARTICIPANT_JOINED || {}
  138. glob_mx.qxi_cb.PARTICIPANT_UPDATED.coninc_conection_event = coninc_conection_event
  139. glob_mx.qxi_cb.PARTICIPANT_LEFT.pleft = pleft
  140. glob_mx.qxi_cb.PARTICIPANT_JOINED.pjoin = pjoin
  141. glob_mx.qxi_cb.CONFERENCE_JOINED.conf_joined = conf_joined
  142. clog("CONINC js")
  143. function get_coninc_status(){
  144. clog("CON_INC",get_participants())
  145. }
  146. // get_coninc_status()
  147. // exp_api_dbg("CON_INC")
  148. // clog("CON_INC",{})