Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/106.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Websocket 西纳特拉蒸汽辅助设备有限公司';行不通 需要'sinatra/base' 类计数器_Websocket_Sinatra - Fatal编程技术网

Websocket 西纳特拉蒸汽辅助设备有限公司';行不通 需要'sinatra/base' 类计数器

Websocket 西纳特拉蒸汽辅助设备有限公司';行不通 需要'sinatra/base' 类计数器,websocket,sinatra,Websocket,Sinatra,摘自 get'/stream'do 流出| 出来 require 'sinatra/base' class Counter < Sinatra::Base set :server, 'thin' # 'webrick' doesn't work either get '/' do haml :index end get '/stream' do |out| out << 'first sentence'

摘自

get'/stream'do
流出|
出来
require 'sinatra/base'

class Counter < Sinatra::Base
    set :server, 'thin' # 'webrick' doesn't work either
    get '/' do
        haml :index
    end


    get '/stream' do |out|
        out << 'first sentence'
            sleep 0.5
            out << 'second sentence'
            sleep 0.5

    end
    run!
end
get '/stream' do
  stream do |out|
    out << "It's gonna be legen -\n"
    sleep 0.5
    out << " (wait for it) \n"
    sleep 1
    out << "- dary!\n"
  end
end