Fixed not-working long-polling example

In streaming section, the long polling example first called #body with
Sinatra::Helpers::Stream then again with ["subscribed"].
This resulted in instant rendering of "subscribed" and closing of the
connection.
This commit is contained in:
detomastah 2014-11-15 18:42:37 +01:00
parent 4e92d604be
commit 67fe2d2917
6 changed files with 30 additions and 42 deletions

View File

@ -1566,13 +1566,11 @@ connections = []
get '/subscribe' do
# Client-Registrierung beim Server, damit Events mitgeteilt werden können
stream(:keep_open) { |out| connections << out }
# tote Verbindungen entfernen
connections.reject!(&:closed?)
# Rückmeldung
"Angemeldet"
stream(:keep_open) do |out|
connections << out
# tote Verbindungen entfernen
connections.reject!(&:closed?)
end
end
post '/:message' do

View File

@ -1540,13 +1540,11 @@ connexions = []
get '/souscrire' do
# abonne un client aux évènements du serveur
stream(:keep_open) { |out| connexions << out }
# purge les connexions abandonnées
connexions.reject!(&:closed?)
# compte-rendu
"abonné"
stream(:keep_open) do |out|
connexions << out
# purge les connexions abandonnées
connexions.reject!(&:closed?)
end
end
post '/message' do

View File

@ -1439,13 +1439,11 @@ connections = []
get '/subscribe' do
# サーバイベントにおけるクライアントの関心を登録
stream(:keep_open) { |out| connections << out }
# 死んでいるコネクションを排除
connections.reject!(&:closed?)
# 肯定応答
"subscribed"
stream(:keep_open) do |out|
connections << out
# 死んでいるコネクションを排除
connections.reject!(&:closed?)
end
end
post '/message' do

View File

@ -1525,13 +1525,11 @@ connections = []
get '/subscribe' do
# register a client's interest in server events
stream(:keep_open) { |out| connections << out }
# purge dead connections
connections.reject!(&:closed?)
# acknowledge
"subscribed"
stream(:keep_open) do |out|
connections << out
# purge dead connections
connections.reject!(&:closed?)
end
end
post '/message' do

View File

@ -1558,13 +1558,11 @@ connections = []
get '/subscribe' do
# register a client's interest in server events
stream(:keep_open) { |out| connections << out }
# purge dead connections
connections.reject!(&:closed?)
# acknowledge
"subscribed"
stream(:keep_open) do |out|
connections << out
# purge dead connections
connections.reject!(&:closed?)
end
end
post '/:message' do

View File

@ -1426,13 +1426,11 @@ connections = []
get '/subscribe' do
# регистрация клиента
stream(:keep_open) { |out| connections << out }
# удаление "мертвых клиентов"
connections.reject!(&:closed?)
# допуск
"subscribed"
stream(:keep_open) do |out|
connections << out }
# удаление "мертвых клиентов"
connections.reject!(&:closed?)
end
end
post '/message' do