def on_message(self, message): dc_sw = self.server_app_websockets.get("DATA_COLLECTION") if dc_sw: msg_dict = ujson.loads(message) msg_type = msg_dict.get('msg_type', 'UNKNOWN') if msg_type is 'UNKNOWN': msg_type = msg_dict.get('type', 'UNKNOWN') if msg_type == 'EXPERIMENT_SELECTED': dc_sw.data_collection_state[ 'active_experiment'] = msg_dict.get('name') elif msg_type == 'OPEN_USER_MANUAL': from webserver import ControlFeedbackServer ControlFeedbackServer.openUserManual() msg_type = 'UNKNOWN' if msg_type is not 'UNKNOWN': dc_sw.write_message(message) else: print("") print( "WARNING: Data Collection Web Socket is not Running. Msg not sent. Is the Data Collection application running?" ) print("")
def on_message(self, message): dc_sw = self.server_app_websockets.get("DATA_COLLECTION") if dc_sw: msg_dict = ujson.loads(message) msg_type = msg_dict.get('msg_type', 'UNKNOWN') if msg_type is 'UNKNOWN': msg_type = msg_dict.get('type', 'UNKNOWN') if msg_type == 'EXPERIMENT_SELECTED': dc_sw.data_collection_state['active_experiment'] = msg_dict.get('name') elif msg_type == 'OPEN_USER_MANUAL': from webserver import ControlFeedbackServer ControlFeedbackServer.openUserManual() msg_type = 'UNKNOWN' if msg_type is not 'UNKNOWN': dc_sw.write_message(message) else: print("") print("WARNING: Data Collection Web Socket is not Running. Msg not sent. Is the Data Collection application running?") print("")
Created on Thu Feb 20 23:43:45 2014 @author: Sol """ from register_server import ConferoBonjourService from webserver import ControlFeedbackServer from psychopy.iohub import Loader, load from findserver import findConferoViewServer import os if __name__ == "__main__": app_config = load(file(os.path.abspath(r'..\settings\app_config.yaml'), 'r'), Loader=Loader) print print "Confero Server Starting... " bonsvc = None server_ip = app_config.get('http_address',None) if server_ip.lower() in [None, 'default', 'auto', 'bonjour']: bonsvc = ConferoBonjourService() view_server_info = findConferoViewServer() app_config['http_address'] = view_server_info['ip'] app_config['http_port'] = view_server_info['port'] print "Registered Confero Server with Bonjour for ip", app_config['http_address'],' : ',app_config['http_port'] print else: print " Confero Server being started with app_config IP settings:", app_config['http_address'],' : ',app_config['http_port'] print server = ControlFeedbackServer(app_config, bonsvc) server.serveForever()