Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'logger'
- module EventMachine
- module Protocols
- module Thiamis
- include EM::Protocols::LineText2
- include EM::Deferrable
- @log = Logger.new(STDOUT)
- @log.formatter = proc { |severity, datetime, progname, msg| msg.split("\n").map {|line| "#{datetime} #{progname}#{severity}: #{line}"}.join("\n") + "\n"}
- @log.info "bzz"
- def initialize *args
- super
- init_protocol_state
- end
- def init_protocol_state
- @state = :write
- @queue = []
- end
- def post_init
- (EM.spawn {|x| x.send_server_greeting}).notify(self)
- end
- def send_server_greeting
- send_thiamis "hello_plz"
- end
- def send_thiamis(data)
- @log.info data.inspect
- send_data "220 #{data}\r\n"
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement