Skip to content

Instantly share code, notes, and snippets.

@deflis
Forked from anonymous/Gemfile
Last active May 5, 2023 04:20
Show Gist options
  • Save deflis/6750736 to your computer and use it in GitHub Desktop.
Save deflis/6750736 to your computer and use it in GitHub Desktop.
どどんとふ on Rack !!!
# coding: utf-8
require './dodontof_rack.rb'
map '/DodontoF/DodontoFServer.rb' do
run DodontoFRack.new
end
run Rack::Directory.new('./DodontoF_WebSet/public_html')
# coding: utf-8
Encoding.default_external = 'UTF-8'
#プレイルームデータ(saveData)の相対パス。
$SAVE_DATA_DIR = "./DodontoF_WebSet"
#各画像(キャラクター・マップ)の保存パス
$imageUploadDir = "./DodontoF_WebSet/public_html/imageUploadSpace"
#リプレイデータの保存パス
$replayDataUploadDir = "./DodontoF_WebSet/public_html/DodontoF/replayDataUploadSpace"
#セーブデータの一時保存パス
$saveDataTempDir = "./DodontoF_WebSet/public_html/DodontoF/saveDataTempSpace"
#ファイルアップローダーのパス
$fileUploadDir = "./DodontoF_WebSet/public_html/DodontoF/fileUploadSpace"
#ログイン画面に表示される「お知らせ」メッセージの定義ファイル名
$loginMessageFile = "./DodontoF_WebSet/public_html/DodontoF/loginMessage.html"
#ログイン画面に表示される「更新履歴」の定義ファイル名
$loginMessageBaseFile = "./DodontoF_WebSet/public_html/DodontoF/loginMessageBase.html"
#ログイン状況を記録するファイル
$loginCountFile = './DodontoF_WebSet/public_html/DodontoF/loginCount.txt'
# coding: utf-8
Encoding.default_external = 'UTF-8'
require './DodontoF_WebSet/public_html/DodontoF/DodontoFServer.rb'
def logging(obj, *options)
return unless( $debug )
p obj
end
def loggingForce(obj, *options)
p obj
end
class DodontoFServer
def initialize_with_rack(saveDirInfo, cgiParams, req)
initialize_without_rack(saveDirInfo, cgiParams)
@req = req
end
alias_method :initialize_without_rack, :initialize
alias_method :initialize, :initialize_with_rack
def getRequestData(key)
value = @cgiParams[key]
if( value.nil? )
if( @isWebIf )
value = @req[key]
end
end
return value
end
end
require "./dodontof_config.rb"
class DodontoFRack
def call(env)
input = env['rack.input'].read
env['rack.input'] = StringIO.new(input)
req = Rack::Request.new(env)
cgiParams = getCgiParams(env, req, input)
server = DodontoFServer.new(SaveDirInfo.new(), cgiParams, req)
res = Rack::Response.new do |r|
r.status = 200
if( server.isJsonResult )
r["Content-Type"]= "text/plain; charset=utf-8"
else
r["Content-Type"]= "application/x-msgpack; charset=x-user-defined"
end
if( server.isAddMarker )
r.write "#D@EM>#"
end
if( server.jsonpCallBack )
r["Access-Control-Allow-Origin"] = "*"
r.write "#{server.jsonpCallBack}("
end
r.write server.getResponse
if( server.jsonpCallBack )
r.write ");"
end
if( server.isAddMarker )
r.write "#<D@EM#";
end
end
res.finish
end
def getCgiParams(env, req, input)
if !req.post?
input = env['QUERY_STRING']
end
messagePackedData = DodontoFServer.getMessagePackFromData( input )
return messagePackedData
end
end
source 'https://rubygems.org'
gem 'rack', '~>1.1'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment