mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2025-06-28 21:45:11 +00:00
Move message validation code to where it belongs
This commit is contained in:
@ -5,7 +5,6 @@ import json
|
||||
|
||||
from tornado.websocket import WebSocketHandler
|
||||
|
||||
from tfw.networking import validate_message
|
||||
from tfw.mixins import CallbackMixin
|
||||
from tfw.config.logs import logging
|
||||
|
||||
@ -20,13 +19,18 @@ class TFWProxy:
|
||||
self.proxy_filters = CallbackMixin()
|
||||
self.proxy_callbacks = CallbackMixin()
|
||||
|
||||
self.proxy_filters.subscribe_callback(validate_message)
|
||||
self.proxy_filters.subscribe_callback(self.validate_message)
|
||||
|
||||
self.keyhandlers = {
|
||||
'mirror': self.mirror,
|
||||
'broadcast': self.broadcast
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def validate_message(message):
|
||||
if 'key' not in message:
|
||||
raise ValueError('Invalid TFW message format!')
|
||||
|
||||
def __call__(self, message):
|
||||
try:
|
||||
self.proxy_filters._execute_callbacks(message)
|
||||
|
Reference in New Issue
Block a user