# chat/consumers.py
import json
from channels.generic.websocket import WebsocketConsumer,AsyncWebsocketConsumer
import hrld.tasks_loop
import time
p=print
Mixins = hrld.tasks_loop.Mixins


class DispConsumer():
	async def ws_rec_once(self, text_data):
		print("WS~~ 12")
		msg_data = json.loads(text_data) 
		if "key" in msg_data:
			key = "jm_" + msg_data["key"] 
			mthd = getattr(self,key,None)
			if mthd:
				await mthd(msg_data) 
			else:
				p("METHOD " + key + " NOT FOUND!")
		print("",end="",flush=True)




class ChatConsumer(
	DispConsumer,
	Mixins.DevMixin,
	Mixins.LoneMixinA,
	Mixins.AclTaskMixin,
	Mixins.AconMixin,
	Mixins.LoneMixinB,
	Mixins.DevMroMixin,
	AsyncWebsocketConsumer,
	):
	async def ws_conn0(self):
		print("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
		print("",end="",flush=True)
		self.accept()
	async def ws_disconn(self, close_code):
		pass

