Last active
December 16, 2015 18:29
-
-
Save astjohn/5478361 to your computer and use it in GitHub Desktop.
Attempting to get torquebox stomplets working. Using torquebox 2.3.0. Cookie based session storage, though torquebox_store produces same result.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example coffeescript | |
_initialize_stomp: -> | |
@stomp_client.connect(null, null, (response) => | |
console.log "STOMP CONNECT", response | |
@stomp_client.subscribe("/trips/#{@trip_id}/travel_package", (message) -> | |
console.log "SUBSCRIBED", message | |
) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# == Chrome Console, js output == # | |
STOMP CONNECT | |
Object {command: "CONNECTED", headers: Object, body: "", toString: function} | |
body: "" | |
command: "CONNECTED" | |
headers: Object | |
toString: function () { | |
__proto__: Object | |
# == Chrome Websockets - Headers == # | |
Request URL:ws://127.0.0.1:8675/ | |
Request Method:GET | |
Status Code:101 Web Socket Protocol Handshake - IETF-07 | |
Request Headersview source | |
Cache-Control:no-cache | |
Connection:Upgrade | |
Cookie:JSESSIONID=UuAYKzNjwREJgR1Q+3ApGKOg | |
Host:127.0.0.1:8675 | |
Origin:http://127.0.0.1:8080 | |
Pragma:no-cache | |
Sec-WebSocket-Extensions:x-webkit-deflate-frame | |
Sec-WebSocket-Key:ioWo5mgmJ2fT3I7UQVj8qA== | |
Sec-WebSocket-Version:13 | |
Upgrade:websocket | |
Response Headersview source | |
Connection:Upgrade | |
Origin:http://127.0.0.1:8080 | |
Sec-WebSocket-Accept:QhaiqYugLL/SNVa4DCgsmYd8epA= | |
Sec-WebSocket-Location:ws://127.0.0.1:8675/ | |
Upgrade:WebSocket | |
# == Chrome Websockets - Frames == # | |
CONNECT | |
login:null | |
passcode:null | |
accept-version:1.0,1.1 | |
CONNECTED | |
session:session-1 | |
server:Stilts/0.1.28 | |
version:1.1 | |
SUBSCRIBE | |
destination:/trips/517bc988fe75bd556800002b/travel_package | |
id:sub-0 | |
# == Chrome Websockets - Cookies == # | |
Request Cookies | |
35 | |
JSESSIONID - UuAYKzNjwREJgR1Q+3ApGKOg | |
Response Cookies | |
0 | |
# == Torquebox STDOUT == # | |
16:15:46,989 INFO [stdout] (New I/O server worker #1-2) ON SUBSCRIBE | |
16:15:46,989 INFO [stdout] (New I/O server worker #1-2) SESSION | |
16:15:46,991 INFO [stdout] (New I/O server worker #1-2) {} | |
16:15:46,992 INFO [stdout] (New I/O server worker #1-2) org.projectodd.stilts.stomp.server.helpers.SimpleStompSession@e322603 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /config/torquebox.rb | |
TorqueBox.configure do | |
ruby do | |
version "1.9" | |
end | |
topic '/topics/trips' | |
stomplet TravelPackageStomplet do | |
route '/trips/:id/travel_package' | |
end | |
# etc... | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /stomplets/travel_package_stomplet.rb | |
class TravelPackageStomplet < TorqueBox::Stomp::JmsStomplet | |
include TorqueBox::Injectors | |
def initialize | |
super | |
@destination = inject('/topics/trips') | |
end | |
def on_subscribe(subscriber) | |
puts "ON SUBSCRIBE" | |
# check session | |
puts "SESSION" | |
session = subscriber.session | |
puts session.to_json | |
puts session | |
subscribe_to(subscriber, @destination) | |
end | |
def on_message(stomp_message, session) | |
# check session | |
puts "ON MESSAGE" | |
#send_to(@destination, stomp_message) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment