onstomp 1.0.0pre1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. data/README.md +1 -1
  2. data/Rakefile +8 -0
  3. data/examples/openuri.rb +36 -0
  4. data/lib/onstomp.rb +4 -0
  5. data/lib/onstomp/client.rb +6 -5
  6. data/lib/onstomp/components.rb +0 -1
  7. data/lib/onstomp/components/frame_headers.rb +35 -38
  8. data/lib/onstomp/components/threaded_processor.rb +13 -0
  9. data/lib/onstomp/connections/base.rb +15 -8
  10. data/lib/onstomp/connections/stomp_1.rb +0 -6
  11. data/lib/onstomp/connections/stomp_1_0.rb +8 -0
  12. data/lib/onstomp/connections/stomp_1_1.rb +8 -0
  13. data/lib/onstomp/failover.rb +16 -0
  14. data/lib/onstomp/failover/buffers.rb +8 -0
  15. data/lib/onstomp/failover/buffers/written.rb +91 -0
  16. data/lib/onstomp/failover/client.rb +127 -0
  17. data/lib/onstomp/failover/failover_configurable.rb +63 -0
  18. data/lib/onstomp/failover/failover_events.rb +96 -0
  19. data/lib/onstomp/failover/new_with_failover.rb +20 -0
  20. data/lib/onstomp/failover/pools.rb +8 -0
  21. data/lib/onstomp/failover/pools/base.rb +39 -0
  22. data/lib/onstomp/failover/pools/round_robin.rb +17 -0
  23. data/lib/onstomp/failover/uri.rb +34 -0
  24. data/lib/onstomp/interfaces/client_configurable.rb +2 -6
  25. data/lib/onstomp/interfaces/client_events.rb +4 -0
  26. data/lib/onstomp/interfaces/connection_events.rb +3 -3
  27. data/lib/onstomp/interfaces/event_manager.rb +8 -0
  28. data/lib/onstomp/interfaces/uri_configurable.rb +7 -7
  29. data/lib/onstomp/open-uri.rb +37 -0
  30. data/lib/onstomp/open-uri/client_extensions.rb +88 -0
  31. data/lib/onstomp/open-uri/message_queue.rb +38 -0
  32. data/lib/onstomp/version.rb +1 -1
  33. data/spec/onstomp/client_spec.rb +1 -4
  34. data/spec/onstomp/components/frame_headers_spec.rb +2 -5
  35. data/spec/onstomp/connections/stomp_1_0_spec.rb +22 -0
  36. data/spec/onstomp/connections/stomp_1_1_spec.rb +22 -0
  37. data/spec/onstomp/connections/stomp_1_spec.rb +2 -19
  38. data/spec/onstomp/connections_spec.rb +4 -0
  39. data/spec/onstomp/failover/buffers/written_spec.rb +8 -0
  40. data/spec/onstomp/failover/client_spec.rb +38 -0
  41. data/spec/onstomp/failover/failover_events_spec.rb +75 -0
  42. data/spec/onstomp/failover/new_with_failover_spec.rb +16 -0
  43. data/spec/onstomp/failover/pools/base_spec.rb +54 -0
  44. data/spec/onstomp/failover/pools/round_robin_spec.rb +27 -0
  45. data/spec/onstomp/failover/uri_spec.rb +21 -0
  46. data/spec/onstomp/full_stacks/failover_spec.rb +55 -0
  47. data/spec/onstomp/full_stacks/onstomp_spec.rb +15 -0
  48. data/spec/onstomp/full_stacks/open-uri_spec.rb +40 -0
  49. data/spec/onstomp/full_stacks/ssl/README +6 -0
  50. data/spec/onstomp/full_stacks/ssl/broker_cert.csr +17 -0
  51. data/spec/onstomp/full_stacks/ssl/broker_cert.pem +72 -0
  52. data/spec/onstomp/full_stacks/ssl/broker_key.pem +27 -0
  53. data/spec/onstomp/full_stacks/ssl/client_cert.csr +17 -0
  54. data/spec/onstomp/full_stacks/ssl/client_cert.pem +72 -0
  55. data/spec/onstomp/full_stacks/ssl/client_key.pem +27 -0
  56. data/spec/onstomp/full_stacks/ssl/demoCA/cacert.pem +17 -0
  57. data/spec/onstomp/full_stacks/ssl/demoCA/index.txt +2 -0
  58. data/spec/onstomp/full_stacks/ssl/demoCA/index.txt.attr +1 -0
  59. data/spec/onstomp/full_stacks/ssl/demoCA/index.txt.attr.old +1 -0
  60. data/spec/onstomp/full_stacks/ssl/demoCA/index.txt.old +1 -0
  61. data/spec/onstomp/full_stacks/ssl/demoCA/newcerts/01.pem +72 -0
  62. data/spec/onstomp/full_stacks/ssl/demoCA/newcerts/02.pem +72 -0
  63. data/spec/onstomp/full_stacks/ssl/demoCA/private/cakey.pem +17 -0
  64. data/spec/onstomp/full_stacks/ssl/demoCA/serial +1 -0
  65. data/spec/onstomp/full_stacks/ssl/demoCA/serial.old +1 -0
  66. data/spec/onstomp/full_stacks/test_broker.rb +251 -0
  67. data/spec/onstomp/interfaces/connection_events_spec.rb +3 -1
  68. data/spec/onstomp/open-uri/client_extensions_spec.rb +113 -0
  69. data/spec/onstomp/open-uri/message_queue_spec.rb +29 -0
  70. data/spec/onstomp/open-uri_spec.rb +43 -0
  71. data/spec/spec_helper.rb +2 -0
  72. data/yard_extensions.rb +5 -1
  73. metadata +82 -8
  74. data/lib/onstomp/components/nil_processor.rb +0 -20
  75. data/spec/onstomp/components/nil_processor_spec.rb +0 -32
@@ -0,0 +1,27 @@
1
+ -----BEGIN RSA PRIVATE KEY-----
2
+ MIIEogIBAAKCAQEAr2Kt6gsrPaYO40qytboypatf8vBagyJM/wWdviW7aGH1Vi4i
3
+ nCv5O6KXN6o3F0DNEpd2cxkkxVl4RUVdK5zf6dJW11y5ylNzoWJw31Kv+31rt2h6
4
+ CGjoSqta6eakzTidLlVREUg8K1eoVTdCEQzpLOd500zILp6SStyLZnm/YuB1Sdc3
5
+ Yk46R3rAL3WMKHBQiCSueusvpndgZHcN4sJO5WIF+icgXFNygBbmr/U1WqlqX2AF
6
+ Ktj+qaQtqsSBNfxRinyfDEDqQGGH7ApgOUQusPZ3eQG2vxXSZc1q5CEFWVPZauc3
7
+ 6s6jsc/DcPwsQD0Sv/mEMsqDxuU9qij/eJ0DFwIDAQABAoIBAGSLes541rJB97kA
8
+ AtHBy/VD+P6qIgmZaXCuBI+UzAp8Vgyw6DCF2R0CChTkZS7UfHxTDpnPaVAmCZgU
9
+ uuQczBUc+6H9S5mdG+YCLFkq6y6O6Wi84XDey4S7FaSQEByCf0GnsZDpy2zBlQQ9
10
+ aIej0i1nCmVDWGO5jn6STuxRkZGZz0+BPEe0kdZIGDl1NvBVy55Vpy4x2ccYa80D
11
+ yZycWtkO65x0RKAZhnaVdDD1vbdvEGPlEmCsoGXn2ahx4AcuZPOIxSz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1,2 @@
1
+ V 210218165001Z 01 unknown /C=US/ST=Nowheres/O=Stomper Testing/OU=SSL Testing/CN=My Broker
2
+ V 210218165725Z 02 unknown /C=US/ST=Nowheres/O=Stomper Testing/OU=SSL Testing/CN=My Client
@@ -0,0 +1 @@
1
+ unique_subject = yes
@@ -0,0 +1 @@
1
+ unique_subject = yes
@@ -0,0 +1 @@
1
+ V 210218165001Z 01 unknown /C=US/ST=Nowheres/O=Stomper Testing/OU=SSL Testing/CN=My Broker
@@ -0,0 +1,72 @@
1
+ Certificate:
2
+ Data:
3
+ Version: 3 (0x2)
4
+ Serial Number: 1 (0x1)
5
+ Signature Algorithm: sha1WithRSAEncryption
6
+ Issuer: C=US, ST=Nowheres, L=Stomper, O=Stomper Testing, OU=CA Testing, CN=Stomper CA
7
+ Validity
8
+ Not Before: Feb 21 16:50:01 2011 GMT
9
+ Not After : Feb 18 16:50:01 2021 GMT
10
+ Subject: C=US, ST=Nowheres, O=Stomper Testing, OU=SSL Testing, CN=My Broker
11
+ Subject Public Key Info:
12
+ Public Key Algorithm: rsaEncryption
13
+ Public-Key: (2048 bit)
14
+ Modulus:
15
+ 00:eb:dd:be:2d:87:54:13:ce:4c:e1:bd:c9:c8:e0:
16
+ 18:b0:50:f1:30:c8:6e:22:7a:bc:c6:ea:3f:e2:c4:
17
+ 24:d9:8c:41:94:54:d4:e0:7b:5c:6c:dd:bd:41:8f:
18
+ bd:aa:98:c2:f0:e9:13:7e:36:5a:97:57:e4:6a:04:
19
+ 08:aa:12:2b:68:4b:9d:5a:40:92:41:57:5b:2e:d2:
20
+ e1:f4:f8:c4:31:dd:6c:2d:4c:12:ab:80:72:71:39:
21
+ 4e:aa:14:b8:f6:35:e8:07:9f:a2:a3:b8:a6:08:8d:
22
+ 60:d5:53:01:38:8c:aa:17:e9:b0:b3:8c:e3:d9:4d:
23
+ 14:02:da:9a:ff:6f:5b:65:ba:c3:56:80:b0:de:8e:
24
+ c8:25:3f:1b:a0:ac:80:1c:38:e0:77:4e:c6:5d:92:
25
+ 44:97:c3:f8:ba:9a:02:83:a8:1b:57:3b:38:d6:7d:
26
+ 7f:95:86:f4:c2:de:51:d0:ee:a1:30:b4:39:9a:f6:
27
+ 58:03:62:93:94:a5:72:72:a2:5c:7e:cf:54:7f:57:
28
+ 92:46:f8:f7:b1:79:56:20:bd:95:25:d5:11:5d:c0:
29
+ 5c:c7:cd:cf:44:8f:88:68:e1:6f:c0:ca:2e:db:fc:
30
+ d0:19:82:36:b1:3f:20:82:df:ce:a6:55:44:02:51:
31
+ 8b:6c:4f:a1:26:b3:41:e8:0b:a8:0c:8f:67:65:92:
32
+ ee:df
33
+ Exponent: 65537 (0x10001)
34
+ X509v3 extensions:
35
+ X509v3 Basic Constraints:
36
+ CA:FALSE
37
+ Netscape Comment:
38
+ OpenSSL Generated Certificate
39
+ X509v3 Subject Key Identifier:
40
+ 5C:28:4D:B8:A3:D7:CB:43:2C:1C:DB:0F:7B:75:99:85:44:4E:D8:A1
41
+ X509v3 Authority Key Identifier:
42
+ keyid:7C:4F:50:BF:C6:57:97:6B:D9:1C:F1:92:EF:B5:66:47:94:79:15:74
43
+
44
+ Signature Algorithm: sha1WithRSAEncryption
45
+ 51:2f:da:d1:a4:9f:97:77:00:69:bb:04:85:34:75:bd:2e:ad:
46
+ 45:83:a7:95:f1:83:5d:52:1e:65:79:ee:5b:a0:f5:7b:82:53:
47
+ 88:c3:fc:89:c8:4f:68:4e:80:8a:cb:53:4f:44:a8:6d:8c:be:
48
+ be:74:19:ff:75:52:14:3b:70:42:87:cf:fc:90:58:7e:c9:cd:
49
+ d4:a2:b8:15:74:e8:51:ce:9c:73:ca:a5:29:76:4a:f3:a4:26:
50
+ f3:70:c5:8e:5f:cf:fe:7d:81:de:43:9e:36:c0:87:7b:66:02:
51
+ 7f:02:2d:64:48:19:be:74:4a:27:cd:c5:56:c5:ff:96:1a:02:
52
+ 3a:2f
53
+ -----BEGIN CERTIFICATE-----
54
+ MIIDTzCCArigAwIBAgIBATAN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8ichPaE6A
70
+ istTT0SobYy+vnQZ/3VSFDtwQofP/JBYfsnN1KK4FXToUc6cc8qlKXZK86Qm83DF
71
+ jl/P/n2B3kOeNsCHe2YCfwItZEgZvnRKJ83FVsX/lhoCOi8=
72
+ -----END CERTIFICATE-----
@@ -0,0 +1,72 @@
1
+ Certificate:
2
+ Data:
3
+ Version: 3 (0x2)
4
+ Serial Number: 2 (0x2)
5
+ Signature Algorithm: sha1WithRSAEncryption
6
+ Issuer: C=US, ST=Nowheres, L=Stomper, O=Stomper Testing, OU=CA Testing, CN=Stomper CA
7
+ Validity
8
+ Not Before: Feb 21 16:57:25 2011 GMT
9
+ Not After : Feb 18 16:57:25 2021 GMT
10
+ Subject: C=US, ST=Nowheres, O=Stomper Testing, OU=SSL Testing, CN=My Client
11
+ Subject Public Key Info:
12
+ Public Key Algorithm: rsaEncryption
13
+ Public-Key: (2048 bit)
14
+ Modulus:
15
+ 00:af:62:ad:ea:0b:2b:3d:a6:0e:e3:4a:b2:b5:ba:
16
+ 32:a5:ab:5f:f2:f0:5a:83:22:4c:ff:05:9d:be:25:
17
+ bb:68:61:f5:56:2e:22:9c:2b:f9:3b:a2:97:37:aa:
18
+ 37:17:40:cd:12:97:76:73:19:24:c5:59:78:45:45:
19
+ 5d:2b:9c:df:e9:d2:56:d7:5c:b9:ca:53:73:a1:62:
20
+ 70:df:52:af:fb:7d:6b:b7:68:7a:08:68:e8:4a:ab:
21
+ 5a:e9:e6:a4:cd:38:9d:2e:55:51:11:48:3c:2b:57:
22
+ a8:55:37:42:11:0c:e9:2c:e7:79:d3:4c:c8:2e:9e:
23
+ 92:4a:dc:8b:66:79:bf:62:e0:75:49:d7:37:62:4e:
24
+ 3a:47:7a:c0:2f:75:8c:28:70:50:88:24:ae:7a:eb:
25
+ 2f:a6:77:60:64:77:0d:e2:c2:4e:e5:62:05:fa:27:
26
+ 20:5c:53:72:80:16:e6:af:f5:35:5a:a9:6a:5f:60:
27
+ 05:2a:d8:fe:a9:a4:2d:aa:c4:81:35:fc:51:8a:7c:
28
+ 9f:0c:40:ea:40:61:87:ec:0a:60:39:44:2e:b0:f6:
29
+ 77:79:01:b6:bf:15:d2:65:cd:6a:e4:21:05:59:53:
30
+ d9:6a:e7:37:ea:ce:a3:b1:cf:c3:70:fc:2c:40:3d:
31
+ 12:bf:f9:84:32:ca:83:c6:e5:3d:aa:28:ff:78:9d:
32
+ 03:17
33
+ Exponent: 65537 (0x10001)
34
+ X509v3 extensions:
35
+ X509v3 Basic Constraints:
36
+ CA:FALSE
37
+ Netscape Comment:
38
+ OpenSSL Generated Certificate
39
+ X509v3 Subject Key Identifier:
40
+ 7A:FC:5D:4F:48:8F:41:43:EA:E5:A6:14:2D:30:19:E5:63:70:43:5C
41
+ X509v3 Authority Key Identifier:
42
+ keyid:7C:4F:50:BF:C6:57:97:6B:D9:1C:F1:92:EF:B5:66:47:94:79:15:74
43
+
44
+ Signature Algorithm: sha1WithRSAEncryption
45
+ 75:80:be:12:d8:7d:64:78:1f:62:97:a9:cd:0a:84:89:15:43:
46
+ ca:5b:a3:72:77:73:f1:aa:06:59:15:75:0b:1b:7d:79:c3:9f:
47
+ d5:3d:e5:70:df:64:ec:a4:27:d9:a3:49:02:b0:75:89:bd:dc:
48
+ 9b:c4:79:33:14:38:93:2b:d8:3c:01:e6:d0:2a:56:06:6a:ba:
49
+ 49:56:5a:f7:6c:49:dd:b0:5c:49:be:68:09:7d:75:2e:9f:49:
50
+ ed:e1:1e:49:6b:f1:cc:1c:1c:be:1e:ac:a9:ee:44:7b:15:32:
51
+ e0:b1:a6:9c:48:a4:1c:5a:55:66:0f:86:95:c0:02:e8:b7:a8:
52
+ b9:9d
53
+ -----BEGIN CERTIFICATE-----
54
+ MIIDTzCCArigAwIBAgIBAjANBgkqhkiG9w0BAQUFADB2MQswCQYDVQQGEwJVUzER
55
+ MA8GA1UECAwITm93aGVyZXMxEDAOBgNVBAcMB1N0b21wZXIxGDAWBgNVBAoMD1N0
56
+ b21wZXIgVGV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/dEE+/ufP0jWSovRlfEeohQALlR8MNCPy+IN3NVBhF045y6kowE0
17
+ -----END ENCRYPTED PRIVATE KEY-----
@@ -0,0 +1,251 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ # This is meant to provide basic testing of the full IO of an OnStomp client.
4
+ # It is not designed to handle more than one client at a time.
5
+ class TestBroker
6
+ class StopThread < StandardError; end
7
+
8
+ attr_reader :messages, :sessions
9
+
10
+ def initialize(port=61613)
11
+ @sessions = []
12
+ @messages = Hash.new { |h,k| h[k] = [] }
13
+ @subscribes = Hash.new { |h,k| h[k] = [] }
14
+ @sub_mutex = Mutex.new
15
+ @session_mutex = Mutex.new
16
+ @port = port
17
+ begin
18
+ @socket = TCPServer.new @port
19
+ rescue Exception => ex
20
+ $stdout.puts "Could not bind: #{ex}"
21
+ end
22
+ @session_class = Session10
23
+ end
24
+
25
+ def kill_sessions
26
+ @session_mutex.synchronize do
27
+ @sessions.each do |s|
28
+ s.kill
29
+ end
30
+ @sessions.clear
31
+ end
32
+ end
33
+
34
+ def enqueue_message s
35
+ @sub_mutex.synchronize do
36
+ msg = OnStomp::Components::Frame.new 'MESSAGE', {}, s.body
37
+ s.headers.each do |k,v|
38
+ msg.headers.append k, v
39
+ end
40
+ msg[:'message-id'] = "msg-#{Time.now.to_f}"
41
+ dest = msg[:destination]
42
+ #$stdout.puts "Enqueuing on #{dest}"
43
+ if !@subscribes[dest].empty?
44
+ session, subid = @subscribes[dest].first
45
+ deliver_message msg, session, subid
46
+ else
47
+ @messages[dest] << msg
48
+ end
49
+ end
50
+ #$stdout.puts "Done enqueueing!"
51
+ end
52
+
53
+ def deliver_message msg, sess, subid
54
+ msg[:subscription] = subid
55
+ sess.transmit msg
56
+ end
57
+
58
+ def messages_for dest
59
+ @messages[dest]
60
+ end
61
+
62
+ def bodies_for dest
63
+ messages_for(dest).map { |m| m.body }
64
+ end
65
+
66
+ def subscribe f, session
67
+ @sub_mutex.synchronize do
68
+ #$stdout.puts "Subscribing?"
69
+ dest = f[:destination]
70
+ @subscribes[dest] << [session, f[:id]]
71
+ #$stdout.puts "Any messages? #{@messages[dest].inspect}"
72
+ until @messages[dest].empty?
73
+ msg = @messages[dest].shift
74
+ deliver_message msg, session, f[:id]
75
+ end
76
+ end
77
+ end
78
+
79
+ def unsubscribe f, session
80
+ @sub_mutex.synchronize do
81
+ @subscribes[f[:destination]].reject! do |pair|
82
+ pair.first == session && pair.last == f[:id]
83
+ end
84
+ end
85
+ end
86
+
87
+ def start
88
+ @listener = Thread.new do
89
+ begin
90
+ loop do
91
+ sess = @session_class.new(self, @socket.accept)
92
+ @session_mutex.synchronize do
93
+ @sessions << sess
94
+ end
95
+ end
96
+ rescue StopThread
97
+ rescue Exception
98
+ $stdout.puts "Listener failed: #{$!}"
99
+ stop
100
+ end
101
+ end
102
+ end
103
+
104
+ def stop
105
+ @session.stop if @session
106
+ @listener.raise(StopThread.new) rescue nil
107
+ @listener.join rescue nil
108
+ @socket.close rescue nil
109
+ end
110
+
111
+ def join
112
+ @sessions.each do |s|
113
+ s.join
114
+ end
115
+ end
116
+
117
+ class Session10
118
+ include OnStomp::Interfaces::ClientEvents
119
+
120
+ attr_reader :connection, :socket
121
+ def initialize server, sock
122
+ @server = server
123
+ @socket = sock
124
+ init_events
125
+ init_connection
126
+ # CONNECT/CONNECTED handshake
127
+ connect_frame = connected_frame = nil
128
+ @connection.io_process_read do |f|
129
+ connect_frame ||= f
130
+ end until connect_frame
131
+
132
+ transmit OnStomp::Components::Frame.new('CONNECTED')
133
+ @connection.io_process_write do |f|
134
+ connected_frame ||= f
135
+ end until connected_frame
136
+ @processor.start
137
+ end
138
+
139
+ def init_connection
140
+ @connection = OnStomp::Connections::Stomp_1_0.new(socket, self)
141
+ @processor = OnStomp::Components::ThreadedProcessor.new self
142
+ end
143
+
144
+ def connected?
145
+ @connection.connected?
146
+ end
147
+
148
+ def init_events
149
+ on_subscribe do |s,_|
150
+ #$stdout.puts "Got SUBSCRIBE: #{s.headers.to_hash.inspect}"
151
+ @server.subscribe s, self
152
+ end
153
+
154
+ on_unsubscribe do |u, _|
155
+ #$stdout.puts "Got UNSUBSCRIBE: #{u.headers.to_hash.inspect}"
156
+ @server.unsubscribe u, self
157
+ end
158
+
159
+ on_send do |s,_|
160
+ #$stdout.puts "Got a SEND frame! #{s.body.inspect}"
161
+ @server.enqueue_message s
162
+ end
163
+
164
+ on_disconnect do |d,_|
165
+ @connection.close
166
+ end
167
+
168
+ before_receiving do |f,_|
169
+ if f.header? :receipt
170
+ transmit OnStomp::Components::Frame.new('RECEIPT',
171
+ :'receipt-id' => f[:receipt])
172
+ end
173
+ end
174
+ end
175
+
176
+ def dispatch_transmitted f
177
+ trigger_after_transmitting f
178
+ end
179
+
180
+ def dispatch_received f
181
+ trigger_before_receiving f
182
+ trigger_after_receiving f
183
+ end
184
+
185
+ def transmit frame
186
+ frame.tap do
187
+ trigger_before_transmitting frame
188
+ connection.write_frame_nonblock(frame)
189
+ end
190
+ end
191
+
192
+ def join
193
+ if @connection.connected?
194
+ #@connection.close
195
+ @processor.join
196
+ end
197
+ end
198
+
199
+ def kill
200
+ @socket.close
201
+ @processor.stop
202
+ end
203
+
204
+ def stop
205
+ if @connection.connected?
206
+ @connection.close
207
+ @processor.stop
208
+ end
209
+ end
210
+ end
211
+
212
+ class Session11 < Session10
213
+ def init_events
214
+ super
215
+ end
216
+
217
+ def init_connection
218
+ @connection = OnStomp::Connections::Stomp_1_1.new(socket, self)
219
+ @processor = OnStomp::Components::ThreadedProcessor.new self
220
+ end
221
+ end
222
+
223
+ class StompErrorOnConnectSession < Session10
224
+ end
225
+ end
226
+
227
+ class TestSSLBroker < TestBroker
228
+ SSL_CERT_FILES = {
229
+ :default => {
230
+ :c => File.expand_path('../ssl/broker_cert.pem', __FILE__),
231
+ :k => File.expand_path('../ssl/broker_key.pem', __FILE__)
232
+ }
233
+ }
234
+
235
+ def initialize(port=61612, certs=:default)
236
+ @port = port
237
+ @tcp_socket = TCPServer.new(@port)
238
+ @ssl_context = OpenSSL::SSL::SSLContext.new
239
+ @ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
240
+ cert_files = SSL_CERT_FILES[certs]
241
+ @ssl_context.key = OpenSSL::PKey::RSA.new(File.read(cert_files[:k]))
242
+ @ssl_context.cert = OpenSSL::X509::Certificate.new(File.read(cert_files[:c]))
243
+ @socket = OpenSSL::SSL::SSLServer.new(@tcp_socket, @ssl_context)
244
+ @socket.start_immediately = true
245
+ @session = nil
246
+ @version = '1.1'
247
+ @session_class = StompSession
248
+ @sent_frames = []
249
+ @received_frames = []
250
+ end
251
+ end