valar 0.0.9__tar.gz → 0.0.10__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of valar might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: valar
3
- Version: 0.0.9
3
+ Version: 0.0.10
4
4
  Summary: valar for morghulis
5
5
  Author: LYP
6
6
  Author-email: liuyinpeng@buaa.edu.cn
@@ -76,8 +76,47 @@ VALAR_CHANNEL_HANDLER_MAPPING = "%s.urls.channel_handler_mapping" % BASE_APP
76
76
  ```
77
77
 
78
78
  # root urls
79
+ ```python
80
+ from django.urls import path
81
+
82
+ from valar.channels import ValarSocketSender
83
+ from valar.channels.views import handel_channel
84
+
85
+ urlpatterns = [
86
+ path('socket/<str:handler>', handel_channel),
87
+ ]
88
+
89
+
90
+ async def test_handler(data, sender: ValarSocketSender):
91
+ # print(data, sender.handler, sender.client, sender.uid)
92
+ await sender.to_users({'user': 15}, 15)
93
+ for i in range(3):
94
+ await sender.to_clients({'h': i},sender.client)
95
+
96
+
97
+ channel_handler_mapping = {
98
+ 'test': test_handler
99
+ }
100
+
101
+ ```
102
+
79
103
 
104
+ # asgi
105
+ ```python
106
+ from django.core.asgi import get_asgi_application
107
+ from channels.routing import ProtocolTypeRouter, URLRouter
108
+ from django.urls import re_path
109
+
110
+ from valar.channels import ValarConsumer
80
111
 
112
+ application = ProtocolTypeRouter({
113
+ 'http': get_asgi_application(),
114
+ 'websocket': URLRouter([
115
+ re_path(r'(?P<client>\w+)/$', ValarConsumer.as_asgi()),
116
+ ])
117
+ })
118
+
119
+ ```
81
120
 
82
121
 
83
122
 
@@ -58,8 +58,47 @@ VALAR_CHANNEL_HANDLER_MAPPING = "%s.urls.channel_handler_mapping" % BASE_APP
58
58
  ```
59
59
 
60
60
  # root urls
61
+ ```python
62
+ from django.urls import path
63
+
64
+ from valar.channels import ValarSocketSender
65
+ from valar.channels.views import handel_channel
66
+
67
+ urlpatterns = [
68
+ path('socket/<str:handler>', handel_channel),
69
+ ]
70
+
71
+
72
+ async def test_handler(data, sender: ValarSocketSender):
73
+ # print(data, sender.handler, sender.client, sender.uid)
74
+ await sender.to_users({'user': 15}, 15)
75
+ for i in range(3):
76
+ await sender.to_clients({'h': i},sender.client)
77
+
78
+
79
+ channel_handler_mapping = {
80
+ 'test': test_handler
81
+ }
82
+
83
+ ```
84
+
61
85
 
86
+ # asgi
87
+ ```python
88
+ from django.core.asgi import get_asgi_application
89
+ from channels.routing import ProtocolTypeRouter, URLRouter
90
+ from django.urls import re_path
91
+
92
+ from valar.channels import ValarConsumer
62
93
 
94
+ application = ProtocolTypeRouter({
95
+ 'http': get_asgi_application(),
96
+ 'websocket': URLRouter([
97
+ re_path(r'(?P<client>\w+)/$', ValarConsumer.as_asgi()),
98
+ ])
99
+ })
100
+
101
+ ```
63
102
 
64
103
 
65
104
 
@@ -10,7 +10,7 @@ requires = ['channels==3.0.3']
10
10
 
11
11
  setup(
12
12
  name="valar", # 包名
13
- version="0.0.9", # 版本号
13
+ version="0.0.10", # 版本号
14
14
  author="LYP", # 作者
15
15
  author_email="liuyinpeng@buaa.edu.cn", # 邮箱
16
16
  description="valar for morghulis", # 简短描述
@@ -4,8 +4,8 @@ import json
4
4
  from django.core.exceptions import ImproperlyConfigured
5
5
  from django.conf import settings
6
6
 
7
- from src.valar import ValarResponse
8
- from src.valar.channels import ValarSocketSender
7
+ from .. import ValarResponse
8
+ from ..channels import ValarSocketSender
9
9
 
10
10
 
11
11
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: valar
3
- Version: 0.0.9
3
+ Version: 0.0.10
4
4
  Summary: valar for morghulis
5
5
  Author: LYP
6
6
  Author-email: liuyinpeng@buaa.edu.cn
@@ -76,8 +76,47 @@ VALAR_CHANNEL_HANDLER_MAPPING = "%s.urls.channel_handler_mapping" % BASE_APP
76
76
  ```
77
77
 
78
78
  # root urls
79
+ ```python
80
+ from django.urls import path
81
+
82
+ from valar.channels import ValarSocketSender
83
+ from valar.channels.views import handel_channel
84
+
85
+ urlpatterns = [
86
+ path('socket/<str:handler>', handel_channel),
87
+ ]
88
+
89
+
90
+ async def test_handler(data, sender: ValarSocketSender):
91
+ # print(data, sender.handler, sender.client, sender.uid)
92
+ await sender.to_users({'user': 15}, 15)
93
+ for i in range(3):
94
+ await sender.to_clients({'h': i},sender.client)
95
+
96
+
97
+ channel_handler_mapping = {
98
+ 'test': test_handler
99
+ }
100
+
101
+ ```
102
+
79
103
 
104
+ # asgi
105
+ ```python
106
+ from django.core.asgi import get_asgi_application
107
+ from channels.routing import ProtocolTypeRouter, URLRouter
108
+ from django.urls import re_path
109
+
110
+ from valar.channels import ValarConsumer
80
111
 
112
+ application = ProtocolTypeRouter({
113
+ 'http': get_asgi_application(),
114
+ 'websocket': URLRouter([
115
+ re_path(r'(?P<client>\w+)/$', ValarConsumer.as_asgi()),
116
+ ])
117
+ })
118
+
119
+ ```
81
120
 
82
121
 
83
122
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes