Sha256: c6e3e3ca72ace7598a0daf3070f80a8370a20662d5e8d96c0f8ef1e9b0d9afc0
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
module Seamless class Dispatcher include Singleton def serialize(session,body) queue = session['_seamless_mq'] body << '<?xml version="1.0"?>' body << "<messages version='1.0' sessionid='#{session.session_id}'>" if queue queue.each do |msg| body << msg end session['_seamless_mq']=[] end body << '</messages>' end def outgoing(obj,type,message) queue = obj['session']['_seamless_mq'] if !queue queue = []; obj['session']['_seamless_mq'] = queue end #TODO requestid queue << "<message requestid='' direction='OUTGOING' datatype='JSON' type='#{type}'><![CDATA[" queue << message.to_json queue << ']]></message>' end def incoming(session,request,response) body = request.env['RAW_POST_DATA'] if body node = REXML::Document.new(body) node.root.each_element('//message') do |message| requestid = message.attributes['requestid'] type = message.attributes['type'] text = message.text msg = JSON.parse(text) req = {'requestid'=>requestid, 'session'=>session} MessageBroker.send(req,type,msg) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
seamless-1.0.0 | lib/seamless/dispatcher.rb |