123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
-
-
- // window.roomName = window.location.pathname.split("/").pop()
- /*
- */
- window.ws_path = `/ws/jsto/`
- window.ws_path2 = `/ws/jsto2/`
-
- function roomNameIndex(){
- clog("RNI!")
- if (window.roomName.includes(".") | !window.roomName){
- window.roomName = "aroomlist"
- }
- }
-
-
-
-
- function msto_conf_info(){
- var ret = "init_val"
- try {
- if (msto.conference.href_const){
- ret = msto.conference.href_const
- } else {
- msto.conference.href_const = window.location.href
- ret = msto.conference.href_const
- }
-
- } catch (err){
- ret = "err"
-
- }
- return ret
- }
- function get_conf_info(){
- var href_const = msto_conf_info()
- var state = APP.store.getState()
- var app_conference = state["features/base/conference"]
- var ret = jc({
- href:msto_conf_info(),
- locked:app_conference.locked ? true : false,
- name:app_conference.name,
- num_participants:state["features/base/participants"].length,
- hosts:state["features/base/config"].hosts,
- })
- return ret
- }
-
-
- function connect_ws(ws_path = window.ws_path){
-
- if(!window.roomName){
- // return
- }
-
- if (window.chatSocket && window.chatSocket.readyState < 2) {
- clog("WSS ALLREADY CONNECTED!")
- return
- }
- clog("WSS CONTECTING")
-
- var chatSocket = new WebSocket(
- 'wss://' + window.location.host + ":8943" +
- // '/ws/chat/' + window.roomName + `/?room=${window.roomName}`);
- ws_path + window.roomName + `/?room=${window.roomName}`);
- window.chatSocket =chatSocket
- chatSocket.onmessage = wsfn.onmessage
- chatSocket.onclose = wsfn.onclose
-
-
-
- // window.chatSocket=chatSocket
-
- }
-
-
-
-
-
-
- wsfn = {}
- wsfn.onmessage = function(e) {
- var data = JSON.parse(e.data);
- // clog("WS ONMSG",data)
- if (data.message != undefined){
- wsfn.on_chat_message(data)
- }
- if (data.type != undefined && wsfn[data.type]){
- wsfn[data.type](data,e)
-
- }
-
-
- // chatSocket.onmessage = onmessage
- // onclose
- // clog(data)
- // clog("~",e)
- // var message = data['message'];
- // document.querySelector('#chat-log').value += (message + '\n');
- };
-
-
-
-
- wsfn.pre_config = function(data,e){
- window.pre_config=data
- clog("PRE_CONFIG",data,e)
-
- if (data.config && data.config.password_enabled){
- setPasswordHelper(data.config.password)
- }
-
- }
-
-
-
-
-
-
- wsfn.pingpong = function(data) {
- clog(">< pingpong")
- // if (window.prt && prt.getLocalParticipant(APP.store).role == "moderator"){
- /*
- if (0){
- try {
- wsfn.s({pop:get_conf_info()})
-
- } catch (err){
- clog("rx4_err:",err)
- }
- }
-
-
- if (0 && window.iammod){
- var state = APP.store.getState()
- // locked
-
- // clog("IS MOD TRU")
- wsfn.s({
- pop:state["features/base/participants"].length,
- locked:state["features/base/conference"].locked ? true : false,
-
- // pop:`state["features/base/participants"].length`,
- // locked:`state["features/base/conference"].locked ? true : false`,
- // locked:{a: + ""},
- pop:{href:window.location.href,num_participants:state["features/base/participants"].length},
- abc:"a",
- test:"a",
- })
- } else
- if (!window.prt) {
- clog("window.prt")
- }
- */
- }
-
- wsfn.on_chat_message = function(data) {
- // var data = JSON.parse(e.data);
- var message = data['message'];
- // document.querySelector('#chat-log').value += (message + '\n');
- };
-
- wsfn.onclose = function(e) {
- console.error('Chat socket closed unexpectedly');
-
-
- if (window.location.pathname.length > 2 && window.location.pathname[1] == "f"){
-
- clog("WSS NO CONN")
- } else {
-
- setTimeout(connect_ws,1400)
- }
- clog("window.location.pathname[1]",window.location.pathname[1])
-
-
- };
-
-
- wsfn.s= function(o){
- chatSocket.send(JSON.stringify(o));
- }
- function e(o){
- chatSocket.send(JSON.stringify({"dbg":o}));
- }
- function itx(o){
- ret = ""
- for (var [k,v] of Object.entries(o)){
- ret += k +":" + v.pop + " ~"+ v.t+ "\n"
- // clog(k,v)
- }
- return ret
- }
-
- //
-
-
- /*
- roomNameIndex()
- if (window.location.pathname.length > 2 && window.location.pathname[1] == "f"){
-
- // clog("WSS NO CONN")
- } else {
-
- }
- */
-
- // if
- // connect_ws()
-
- // clog("zzzzzz")
|