Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Communications Backbone System
communications-backbone
Commits
86b61a8f
Verified
Commit
86b61a8f
authored
2 months ago
by
Dan Jones
Browse files
Options
Download
Email Patches
Plain Diff
fix: remove unused imports
parent
3b0ed55a
11-add-websockets
1 merge request
!6
Draft: Resolve "Add websockets"
Pipeline
#262152
failed with stages
in 32 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
8 deletions
+6
-8
api_wrap_socket.py
api_wrap_socket.py
+6
-8
No files found.
api_wrap_socket.py
View file @
86b61a8f
...
@@ -18,17 +18,16 @@
...
@@ -18,17 +18,16 @@
# On disconnect the queue consumer is cancelled so that new
# On disconnect the queue consumer is cancelled so that new
# messages are left in the queue
# messages are left in the queue
import
concurrent.futures
import
json
import
json
import
uuid
import
uuid
import
time
import
time
from
twisted.internet
import
reactor
,
threads
from
twisted.internet
import
reactor
from
twisted.web.server
import
Site
from
twisted.web.server
import
Site
from
twisted.web.resource
import
Resource
from
twisted.web.resource
import
Resource
from
twisted.web.wsgi
import
WSGIResource
from
twisted.web.wsgi
import
WSGIResource
from
autobahn.exception
import
Disconnected
from
autobahn.exception
import
Disconnected
from
autobahn.twisted.resource
import
WebSocketResource
from
autobahn.twisted.resource
import
WebSocketResource
from
autobahn.twisted.websocket
import
WebSocketServerFactory
,
WebSocketServerProtocol
,
listenWS
from
autobahn.twisted.websocket
import
WebSocketServerFactory
,
WebSocketServerProtocol
from
models.client_model
import
ClientModel
from
models.client_model
import
ClientModel
from
models.token_model
import
TokenModel
from
models.token_model
import
TokenModel
from
api_rest
import
create_app
from
api_rest
import
create_app
...
@@ -68,16 +67,12 @@ class SubscriptionServerProtocol(WebSocketServerProtocol):
...
@@ -68,16 +67,12 @@ class SubscriptionServerProtocol(WebSocketServerProtocol):
if
valid
:
if
valid
:
try
:
try
:
client_id
=
parsed
.
get
(
'client_id'
)
client_id
=
parsed
.
get
(
'client_id'
)
client
=
self
.
apiClients
.
get
(
parsed
.
get
(
'
client_id
'
)
)
client
=
self
.
apiClients
.
get
(
client_id
)
if
client
:
if
client
:
self
.
client
=
client
self
.
client
=
client
allow
=
True
allow
=
True
except
Exception
:
except
Exception
:
allow
=
False
allow
=
False
if
allow
:
# setup queue consumer
SubscriptionListener
.
createListener
(
self
)
return
allow
return
allow
...
@@ -92,6 +87,9 @@ class SubscriptionServerProtocol(WebSocketServerProtocol):
...
@@ -92,6 +87,9 @@ class SubscriptionServerProtocol(WebSocketServerProtocol):
Try authentication
Try authentication
"""
"""
allow
=
self
.
auth
(
request
.
headers
)
allow
=
self
.
auth
(
request
.
headers
)
if
allow
:
# setup queue consumer
SubscriptionListener
.
createListener
(
self
)
def
onMessage
(
self
,
payload
,
isBinary
):
def
onMessage
(
self
,
payload
,
isBinary
):
if
not
isBinary
:
if
not
isBinary
:
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment