def get(self): """Renders the main page. When this page is shown, we create a new channel to push asynchronous updates to the client.""" user = self.get_secure_cookie('u') if user is None: user = uuid.uuid4().hex self.set_secure_cookie('u', user) game_key = self.get_argument('g', None) if game_key is None: game_key = user game = Game(key_name = game_key, userX = user, moveX = True, board = ' ') game.put() else: game = Game.get_by_key_name(game_key) if not game.userO: game.userO = user game.put() game_link = '/?g=' + game_key if game: url = channel.create_channel(user + game_key) template_values = {'url': url, 'me': user, 'game_key': game_key, 'game_link': game_link, 'initial_message': GameUpdater(game).get_game_message() } path = os.path.join(os.path.dirname(__file__), 'index.html') self.render(path, **template_values) else: self.write('No such game')
def index(request): # if request.user.is_staff: name = listener_manager.create_listener() duration = listener_manager.EXPIRE_MINUTES url = channel.create_channel(name, duration) listener_manager.add_listener(name) print "create", name, url return render_to_response("logboard/index.html", {"url": url}, context_instance=RequestContext(request))
def index(request): url = '' name = 'test_channel' duration = 10 url = channel.create_channel(name, duration) if request.method == 'POST': content = request.POST.get('content', '') channel.send_message(name, str(content)) return render_to_response('chat/index.html', {'url':url}, context_instance=RequestContext(request))
def index(request): #if request.user.is_staff: name = listener_manager.create_listener() duration = listener_manager.EXPIRE_MINUTES url = channel.create_channel(name, duration) listener_manager.add_listener(name) print 'create', name, url return render_to_response('logboard/index.html', {'url': url}, context_instance=RequestContext(request))
def index(request): url = '' name = 'test_channel' duration = 10 url = channel.create_channel(name, duration) if request.method == 'POST': content = request.POST.get('content','') channel.send_message(name, str(content)) return render_to_response('chat/index.html', {'url':url }, context_instance=RequestContext(request))
def get_channel(channelname): global g_connect if channelname == 'test': g_connect = True url = channel.create_channel(chname) response = make_response( url ) response.content_type = 'text/html' response.headers['Access-Control-Allow-Credentials'] = True response.headers['Access-Control-Allow-Origin'] = '*' return response return None
def connect(): channelName = str(int(time.time())) + str(random.randint(100000, 999999)) url = channel.create_channel(channelName) host = request.args.get('host', '') port = request.args.get('port', '') if (url != '' and url != None and host != '' and host != None and port != '' and port != None): hosts[channelName] = host ports[channelName] = int(port) return jsonify({'status': 'OK', 'url': url}) else: return jsonify({'status': 'error'})
def index(): if not sae: return render_template('single_game.html') try: C = cname = '%d' % randint(10000000, 99999999) from sae import channel socket = channel.create_channel(cname) print socket except Exception as e: return str(e) return render_template('index.html', cname=socket)
def get(self): """Renders the main page. When this page is shown, we create a new channel to push asynchronous updates to the client.""" user = self.get_secure_cookie('u') if user is None: user = uuid.uuid4().hex self.set_secure_cookie('u', user) game_key = self.get_argument('g', None) if game_key is None: game_key = user game = Game(key_name=game_key, userX=user, moveX=True, board=' ') game.put() else: game = Game.get_by_key_name(game_key) if not game.userO: game.userO = user game.put() game_link = '/?g=' + game_key if game: url = channel.create_channel(user + game_key) template_values = { 'url': url, 'me': user, 'game_key': game_key, 'game_link': game_link, 'initial_message': GameUpdater(game).get_game_message() } path = os.path.join(os.path.dirname(__file__), 'index.html') self.render(path, **template_values) else: self.write('No such game')
def get_context_data(self, **kwargs): channel_url = channel.create_channel(settings.PUBLIC_ROOM_NAME) return { 'channel_url': channel_url }
def add(self, chat=False): i = self.get_min() c = 'c' if chat else '' self.__list[i] = chat self.save() return channel.create_channel('%s_%d_%s' % (self.__id, i, c), 1440)