lib/amqp/server.rb in amqp-0.7.0.pre vs lib/amqp/server.rb in amqp-0.7.0
- old
+ new
@@ -1,26 +1,28 @@
+# encoding: utf-8
+
require File.expand_path('../frame', __FILE__)
module AMQP
module Server
def post_init
@buf = ''
@channels = {}
@started = false
end
- def receive_data data
+ def receive_data(data)
@buf << data
unless @started
if @buf.size >= 8
- if @buf.slice!(0,8) == "AMQP\001\001\b\000"
+ if @buf.slice!(0, 8) == "AMQP\001\001\b\000"
send Protocol::Connection::Start.new(
8,
0,
{
- :information => 'Licensed under the Ruby license. See http://github.com/tmm1/amqp',
+ :information => 'Licensed under the Ruby license. See http://github.com/ruby-amqp/amqp',
:copyright => 'Copyright (c) 2008-2009 Aman Gupta',
:platform => 'Ruby/EventMachine',
:version => '0.6.1',
:product => 'SquirrelMQ'
},
@@ -40,11 +42,11 @@
while frame = Frame.parse(@buf)
process_frame frame
end
end
- def process_frame frame
+ def process_frame(frame)
channel = frame.channel
case method = frame.payload
when Protocol::Connection::StartOk
@user = method.response[:LOGIN]
@@ -65,11 +67,11 @@
when Protocol::Access::Request
send Protocol::Access::RequestOk.new(101)
end
end
- def send data, opts = {}
+ def send(data, opts = {})
channel = opts[:channel] ||= 0
data = data.to_frame(channel) unless data.is_a? Frame
data.channel = channel
log 'send', data
@@ -79,21 +81,21 @@
def self.start host = 'localhost', port = 5672
EM.start_server host, port, self
end
private
-
- def log *args
+
+ def log(*args)
require 'pp'
pp args
puts
end
end
end
if __FILE__ == $0
require 'rubygems'
require 'eventmachine'
- EM.run{
+ EM.run {
AMQP::Server.start
}
-end
\ No newline at end of file
+end