mirror of
https://github.com/hequan2017/seal.git
synced 2026-02-02 17:59:03 +08:00
v0.4.3 配合 vue前端
This commit is contained in:
@@ -37,7 +37,13 @@ class EchoConsumer(WebsocketConsumer):
|
||||
|
||||
def connect(self):
|
||||
# 创建channels group, 命名为:用户名 (最好不要中文名字,这里会用名字 建立一个通道,通过这个通道进行通信),并使用channel_layer写入到redis
|
||||
async_to_sync(self.channel_layer.group_add)(self.scope['user'].username, self.channel_name)
|
||||
try:
|
||||
async_to_sync(self.channel_layer.group_add)(self.scope['user'].username, self.channel_name)
|
||||
except Exception as e:
|
||||
# 这里是为了配合 seal-vue 使用,实际项目,请删除下面这一行
|
||||
async_to_sync(self.channel_layer.group_add)("admin", self.channel_name)
|
||||
|
||||
|
||||
# 可以在这里根据 用户 要访问的pod 进行 权限控制
|
||||
path = self.scope['path'].split('/')
|
||||
try:
|
||||
@@ -59,4 +65,8 @@ class EchoConsumer(WebsocketConsumer):
|
||||
self.send(text_data=event["text"])
|
||||
|
||||
def disconnect(self, close_code):
|
||||
async_to_sync(self.channel_layer.group_discard)(self.scope['user'].username, self.channel_name)
|
||||
try:
|
||||
async_to_sync(self.channel_layer.group_discard)(self.scope['user'].username, self.channel_name)
|
||||
except Exception as e:
|
||||
# 这里是为了配合 seal-vue 使用,实际项目,请删除下面这一行
|
||||
async_to_sync(self.channel_layer.group_discard)("admin", self.channel_name)
|
||||
|
||||
@@ -18,6 +18,7 @@ class K8sApi(object):
|
||||
aConfiguration.api_key = {"authorization": "Bearer " + token}
|
||||
aApiClient = client.ApiClient(aConfiguration)
|
||||
v1 = client.CoreV1Api(aApiClient)
|
||||
|
||||
return v1
|
||||
|
||||
def get_node_list(self):
|
||||
|
||||
Reference in New Issue
Block a user