Browse Source

auto commit

master
jfinn 2 years ago
parent
commit
fce857d730
1 changed files with 164 additions and 2 deletions
  1. 164
    2
      wsps/hot_reload_temp_staging.py

+ 164
- 2
wsps/hot_reload_temp_staging.py View File

1
 
1
 
2
+import wsps.tasks_loop
3
+# print("HOTRELOAD")
2
 
4
 
3
-print("HOTRELOAD")
4
 
5
 
5
 
6
 
6
-# def run_to
7
 
7
 
8
 
8
 
9
+
10
+class DevMixin_R1():
11
+
12
+	async def az_call(self, *a,**kw):
13
+		await asyncio.sleep(0.001)
14
+		p("az_call:")
15
+		p(end="",flush=True)
16
+	async def ws_conn(self, *a,**kw):
17
+		if not getattr(glob_cl,"z",None):
18
+			glob_cl.z=self
19
+		# p("????????????")
20
+		await glob_cl.dev_group_add("chat_group_t1.all",self)
21
+		self.group_name= self.scope["url_route"]["kwargs"]["room_name"]
22
+		# await glob_cl.dev_group_add("chat_group_t1.:all",self)
23
+		await glob_cl.dev_group_add(self.group_name,self)
24
+
25
+
26
+
27
+	async def con_ping0(self, text_data):
28
+		p("con_ping0:")
29
+		p(end="",flush=True)
30
+	async def con_ping(self, text_data):
31
+		# p("con_ping:",text_data)
32
+		p("con_ping:")
33
+		p(end="",flush=True)
34
+		# p("!!!.?",flush=True)
35
+		# p(flush=True)
36
+		p(end="",flush=True)
37
+	async def jm_group_size(self, text_data):
38
+		await self.channel_layer.group_send(self.group_name,{"type":"con_ping","return_addr":self.channel_name})
39
+		p("????????\n")
40
+		asyncio.ensure_future(self.az_call())
41
+		# glob_cl.loop.create_task(self.az_call())
42
+		# glob_cl.loop.ensure_future(self.az_call())
43
+		p(end="",flush=True)
44
+		# return
45
+		# await asyncio.sleep(0.001)
46
+		p("!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
47
+		p(end="",flush=True)
48
+
49
+	async def jsto_send(self, text_data):
50
+		p("jsto_send:",type(text_data))
51
+		p(text_data)
52
+		await self.send(text_data = json.dumps(text_data))
53
+
54
+	async def jsend(self, text_data):
55
+		p("jsend:",type(text_data))
56
+		p(text_data)
57
+		await self.send(text_data = json.dumps(text_data["payload"]))
58
+
59
+	async def jm_group_sto_message(self, text_data):
60
+		await self.channel_layer.group_send(self.group_name,{"payload":text_data,"type":"jsto_send"})
61
+	async def jm_group_message(self, text_data):
62
+		await self.channel_layer.group_send(self.group_name,{"payload":text_data,"type":"jsend"})
63
+
64
+	async def jm_mtypex(self, text_data):
65
+		p(self.groups)
66
+
67
+		# p("abc")
68
+		await self.send(text_data=json.dumps({
69
+			"type":"z",
70
+			'm1': {"abc.":123}
71
+
72
+		}))
73
+		# await self.channel_layer.group_send("group1",self.channel_name)
74
+		await self.channel_layer.group_send(self.group_name,{"zz":"HI...","type":"zz"})
75
+		await self.channel_layer.send(self.channel_name,{"zz":"HI","type":"zz"})
76
+
77
+
78
+
79
+	async def zz(self, text_data):
80
+		p("HELO>???",text_data)
81
+
82
+
83
+class DevMixin_R2_DevSto():
84
+
85
+	async def ws_conn(self, *a,**kw):
86
+		self.group_count = 0
87
+		# r'''
88
+		await self.get_group_size({
89
+			"CLIENT_KEY": "ws_sto",
90
+			"group_count": -1,
91
+			"sto_event_type": "group_count",
92
+			"ws_conn":"???",
93
+
94
+
95
+			})
96
+		# '''
97
+		# r'''
98
+		await self.send(text_data = json.dumps({
99
+			"CLIENT_KEY":"ws_sto",
100
+			"sto_event_type": "connection_info",
101
+			"channel_name":self.channel_name,
102
+			"group_name":self.group_name,
103
+		}))
104
+		# '''
105
+
106
+	async def ws_disconn(self, close_code):
107
+		# TODO:JFI maybe call jm_tmp_dev_sto?
108
+		await self.channel_layer.group_send(self.group_name,{"type":"jm_tmp_dev_sto_rec","from":self.channel_name,
109
+			"CLIENT_KEY":"ws_sto",
110
+			"sto_event_type": "user_disconnected",
111
+			"group_name":self.group_name,
112
+			"channel_name":self.channel_name,
113
+
114
+			})
115
+		# r'''
116
+		# '''
117
+		r'''
118
+		await self.send(text_data=json.dumps({
119
+			"sto_event_type": "user_disconnected",
120
+			"channel_name":self.channel_name,
121
+			"group_name":self.group_name,
122
+		}))
123
+		# '''
124
+
125
+	async def group_size_count(self,*a,**kw):
126
+		# await asyncio.sleep(0.1)
127
+
128
+		# p("method/fn:",inspect.stack()[0][3])
129
+		self.gc_t_fin =time.time()
130
+		# await self.send(text_data=json.dumps({"CLIENT_KEY":"ws_sto","group_count":self.group_count,"sto_event_type":"group_count","t_fin":self.gc_t_fin,"t_0":self.gc_t_0,"t_arr":self.gc_t_arr}))
131
+		# await self.send(text_data=json.dumps({"CLIENT_KEY":"ws_sto","group_count":self.group_count,"sto_event_type":"group_count","tx":time_difs(self.gc_t_0,self.gc_t_fin,self.gc_t_arr)}))
132
+		await self.send(text_data=json.dumps({"CLIENT_KEY":"ws_sto","group_count":self.group_count,"sto_event_type":"group_count"}))
133
+		pass
134
+	async def group_size_pong(self,text_data):
135
+		self.group_count += 1
136
+		self.gc_t_arr.append(time.time())
137
+	async def group_size_ping(self,text_data):
138
+		await self.channel_layer.send(text_data["from"],{"type":"group_size_pong","from":self.channel_name})
139
+		# p("group_size_ping")
140
+	async def jm_get_group_size(self,text_data):
141
+		await self.get_group_size(text_data)
142
+	async def get_group_size(self,text_data):
143
+		self.group_count = 0
144
+		self.gc_t_0=time.time()
145
+		self.gc_t_arr=[]
146
+		# p(self.gc_ts1)
147
+		await self.channel_layer.group_send(self.group_name,{"type":"group_size_ping","from":self.channel_name})
148
+		glob_cl.cbs_asap.append(self.group_size_count)
149
+	async def jm_tmp_dev_sto_rec(self,text_data):
150
+		_from = text_data.get("from")
151
+		pass
152
+		if (_from == self.channel_name):
153
+			await self.send(text_data = json.dumps(text_data))
154
+			pass
155
+		else:
156
+			await self.send(text_data = json.dumps(text_data))
157
+
158
+	async def jm_tmp_dev_sto(self,text_data):
159
+		# p("jm_tmp_dev_sto:",text_data)
160
+		await self.channel_layer.group_send(self.group_name,{**text_data,"type":"jm_tmp_dev_sto_rec","from":self.channel_name})
161
+		sto_event_type = text_data.get("sto_event_type")
162
+		if sto_event_type == "db_sync_request":
163
+			pass
164
+			# TODO:JFI not sure if I will allow m
165
+			# await self.get_group_size(text_data)
166
+
167
+
168
+
169
+# def run_to
170
+

Loading…
Cancel
Save