File: stompserver

package info (click to toggle)
stompserver 0.9.9gem-5
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 424 kB
  • sloc: ruby: 2,765; sh: 162; makefile: 3
file content (53 lines) | stat: -rw-r--r-- 1,475 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/user/bin/env ruby

require 'etc'
require 'yaml'
require 'daemons/daemonize'
require 'stomp_server'
require 'optparse'

$STOMP_SERVER = true

$HTTP_ENABLE = false
if $HTTP_ENABLE
  require 'mongrel'
  require 'stomp_server/protocols/http'
end


EventMachine::run do

  ## Get the configuration and initialize the stomp engine
  config = StompServer::Configurator.new
  stomp = StompServer::Run.new(config.opts)
  stomp.start


  # Might want to uncomment this if you are sending large files
  #EventMachine::add_periodic_timer 10, proc {GC.start}
  
  puts "Client authorization enabled" if config.opts[:auth]
  puts "Debug enabled" if config.opts[:debug]

  ## Start protocol handlers

  puts "Stomp protocol handler starting on #{config.opts[:host]} port #{config.opts[:port]}"
  EventMachine.start_server(config.opts[:host], config.opts[:port], StompServer::Protocols::Stomp) {|s| s.instance_eval {
      @@auth_required=stomp.auth_required
      @@queue_manager=stomp.queue_manager
      @@topic_manager=stomp.topic_manager
      @@stompauth = stomp.stompauth
    }
  }

  if $HTTP_ENABLE
    puts "Http protocol handler starting on #{config.opts[:host]} port 8080"
    EventMachine.start_server(config.opts[:host], 8080, StompServer::Protocols::Http) {|s| s.instance_eval {
        @@auth_required=stomp.auth_required
        @@queue_manager=stomp.queue_manager
        @@topic_manager=stomp.topic_manager
        @@stompauth = stomp.stompauth
      }
    }
  end
end