def monitor(request): if not get_cache(request.META['REMOTE_ADDR']): return HttpResponseRedirect('/webvideo/') l_video_port = 0 if request.has_key('last_port'): # handle logout videoserver message l_video_port = request.GET['last_port'] s = controller.init_socket() controller.handle(s, 'stop:%s\r' % l_video_port) time.sleep(1) java_script_on = False video_port = 0 if request.has_key('port'): video_port = request.GET['port'] java_script_on = True # handle login videoserver message s = controller.init_socket() controller.handle(s, 'start:%s\r' % video_port) f = lambda x:('MSIE' in x and 'ie') or 'firefox' OS = f(request.META['HTTP_USER_AGENT']) sites = load_file() d = {'sites':sites, 'os':OS, 'localhttp':config.LOCAL_HTTP, 'serverip':config.VIDEO_SERVER_IP.split(':')[0], 'jsp':java_script_on, 'serverport':video_port } return render_to_response('video_monitor.html', d)
def logout(request): del_cache(request.META['REMOTE_ADDR']) l_video_port = 0 if request.has_key('last_port'): # handle logout videoserver message s = controller.init_socket() l_video_port = request.GET['last_port'] controller.handle(s, 'stop:%s\r' % l_video_port) return HttpResponseRedirect('/webvideo/')