# IPC サーバー require "al_worker_ipc" class IpcServer < AlWorker # イニシャライザでIPCを用意する。 def initialize2() @ipc = Ipc.new() @ipc.chmod = 0666 @ipc.run( self ) end # IPCコマンド idle を定義 # 動作:何もしない def ipc_idle( sock, param ) reply( sock, 200, "OK" ) end # IPCコマンド hello を定義 # 動作:文字列 hello を返す。 def ipc_hello( sock, param ) reply( sock, 200, "OK", reply: "hello" ) end # IPCコマンド upper を定義 # 動作:送られたパラメータの値を大文字にして返す def ipc_upper( sock, param ) param.keys.each { |k| param[k].upcase! } reply( sock, 200, "OK", param ) end end server = IpcServer.new( "ipc_server" ) server.daemon()