import gmod p=print # should this really be a class # class Eobj:pass gx = gmod.gx import json from simple_websocket import Server from simple_websocket.ws import Base import base64 OKBLUE = '\033[94m' ENDC = '\033[0m' import inspect def ws_disconn(sock,*a,**kw): gx.dicard_on_close(sock) ending = json.dumps({ "type":"jm_tmp_dev_sto_rec","from":"self.channel_name", "CLIENT_KEY":"ws_sto", "sto_event_type": "user_disconnected", "group_name":sock.slf["channel_name"], "from????":sock.slf["channel_name"], # "group_name":"self.group_name", "channel_name":sock.slf["channel_name"], }) p("ending:::::::::::::::::::::::::") p(ending) # gx.send_to_channel("all_groups",ending,"SENED") gx.send_to_channel(sock.slf["group_name"],ending,"SENED") # await self.channel_layer.group_send(self.group_name,) # sock.send(json.dumps({"type":"jm_tmp_dev_sto_rec","from":"self.channel_name", # gx.send_to_channel("all_groups",json.dumps({"type":"jm_tmp_dev_sto_rec","from":"self.channel_name", # "CLIENT_KEY":"ws_sto", # "sto_event_type": "user_disconnected", # "group_name":"self.group_name", # "channel_name":"self.channel_name", # }),"sender") # p("DISCONNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",a,kw) pass def ws_conn(sock,*a,**kw): # return sock.slf = {} sock.slf["channel_id"] = hash(sock) sock.slf["channel_name"] = str(sock.slf["channel_id"]) sock.slf["group_name"] = gx.parse_qs(sock.environ["QUERY_STRING"]).get("room","NO_ROOM") gmod.glob["all_ws_conn"].add(sock) # gx.parse_qs gx.add_to_channel(sock,"all_groups") old_group_size = gx.add_to_channel(sock,sock.slf["group_name"]) p(OKBLUE,"ws_conn",a,kw,ENDC) # return sock_info(sock) # my_int = sock.slf["channel_id"] # p(struct.pack("