Class: WAMP::Protocols::Version1
- Inherits:
-
Object
- Object
- WAMP::Protocols::Version1
- Defined in:
- lib/wamp/protocols/version_1.rb
Overview
Describes the WAMP protocol messages per www.wamp.ws/spec#call_message
Instance Method Summary collapse
-
#call(call_id, proc_uri, *args) ⇒ String
Builds the RPC CALL message (client to server) [ TYPE_ID_CALL , callID , procURI , … ].
-
#call_error(call_id, error_uri, error_desc, error_details = nil) ⇒ String
Builds the RPC CALLERROR message (server to client) [ TYPE_ID_CALLERROR , callID , errorURI , errorDesc , errorDetails(Optional) ].
-
#call_result(call_id, result = nil) ⇒ String
Builds the RPC CALLRESULT message (server to client) [ TYPE_ID_CALLRESULT , callID , result ].
-
#event(topic_uri, event) ⇒ String
Builds the PubSub EVENT message (server to client) [ TYPE_ID_EVENT , topicURI , event ].
-
#prefix(prefix, uri) ⇒ String
Builds the PREFIX message (client to server) [ TYPE_ID_PREFIX , prefix , URI ].
-
#publish(topic_uri, event, exclude = nil, elgible = nil) ⇒ String
Builds the PubSub PUBLISH message (client to server) [ TYPE_ID_PUBLISH , topicURI , event ] [ TYPE_ID_PUBLISH , topicURI , event , excludeMe ] [ TYPE_ID_PUBLISH , topicURI , event , exclude , eligible ].
-
#subscribe(topic_uri) ⇒ String
Builds the PubSub SUBSCRIBE message (client to server) [ TYPE_ID_SUBSCRIBE , topicURI ].
-
#unsubscribe(topic_uri) ⇒ String
Builds the PubSub UNSUBSCRIBE message (client to server) [ TYPE_ID_UNSUBSCRIBE , topicURI ].
-
#version ⇒ Integer
The version of the WAMP protocol defined in this class.
-
#welcome(id) ⇒ String
Builds the WELCOME message (server to client) [ TYPE_ID_WELCOME , sessionId , protocolVersion, serverIdent ].
Instance Method Details
#call(call_id, proc_uri, *args) ⇒ String
Builds the RPC CALL message (client to server) [ TYPE_ID_CALL , callID , procURI , … ]
40 41 42 |
# File 'lib/wamp/protocols/version_1.rb', line 40 def call(call_id, proc_uri, *args) [type[:CALL], call_id, proc_uri, *args].to_json end |
#call_error(call_id, error_uri, error_desc, error_details = nil) ⇒ String
Builds the RPC CALLERROR message (server to client) [ TYPE_ID_CALLERROR , callID , errorURI , errorDesc , errorDetails(Optional) ]
64 65 66 67 68 |
# File 'lib/wamp/protocols/version_1.rb', line 64 def call_error(call_id, error_uri, error_desc, error_details = nil) msg = [type[:CALLERROR], call_id, error_uri, error_desc, error_details] msg.delete_if { |x| x.nil? } msg.to_json end |
#call_result(call_id, result = nil) ⇒ String
Builds the RPC CALLRESULT message (server to client) [ TYPE_ID_CALLRESULT , callID , result ]
51 52 53 |
# File 'lib/wamp/protocols/version_1.rb', line 51 def call_result(call_id, result = nil) [type[:CALLRESULT], call_id, result].to_json end |
#event(topic_uri, event) ⇒ String
Builds the PubSub EVENT message (server to client)
[ TYPE_ID_EVENT , topicURI , event ]
114 115 116 |
# File 'lib/wamp/protocols/version_1.rb', line 114 def event(topic_uri, event) [type[:EVENT], topic_uri, event].to_json end |
#prefix(prefix, uri) ⇒ String
Builds the PREFIX message (client to server) [ TYPE_ID_PREFIX , prefix , URI ]
26 27 28 |
# File 'lib/wamp/protocols/version_1.rb', line 26 def prefix(prefix, uri) [type[:PREFIX], prefix, uri].to_json end |
#publish(topic_uri, event, exclude = nil, elgible = nil) ⇒ String
Builds the PubSub PUBLISH message (client to server) [ TYPE_ID_PUBLISH , topicURI , event ] [ TYPE_ID_PUBLISH , topicURI , event , excludeMe ] [ TYPE_ID_PUBLISH , topicURI , event , exclude , eligible ]
101 102 103 104 105 106 107 |
# File 'lib/wamp/protocols/version_1.rb', line 101 def publish(topic_uri, event, exclude = nil, elgible = nil) msg = [type[:PUBLISH], topic_uri, event] msg[3] = exclude unless exclude.nil? msg[4] = elgible unless elgible.nil? msg.to_json end |
#subscribe(topic_uri) ⇒ String
Builds the PubSub SUBSCRIBE message (client to server) [ TYPE_ID_SUBSCRIBE , topicURI ]
75 76 77 |
# File 'lib/wamp/protocols/version_1.rb', line 75 def subscribe(topic_uri) [type[:SUBSCRIBE], topic_uri].to_json end |
#unsubscribe(topic_uri) ⇒ String
Builds the PubSub UNSUBSCRIBE message (client to server) [ TYPE_ID_UNSUBSCRIBE , topicURI ]
83 84 85 |
# File 'lib/wamp/protocols/version_1.rb', line 83 def unsubscribe(topic_uri) [type[:UNSUBSCRIBE], topic_uri].to_json end |
#version ⇒ Integer
Returns The version of the WAMP protocol defined in this class.
8 9 10 |
# File 'lib/wamp/protocols/version_1.rb', line 8 def version 1 end |
#welcome(id) ⇒ String
Builds the WELCOME message (server to client) [ TYPE_ID_WELCOME , sessionId , protocolVersion, serverIdent ]
17 18 19 |
# File 'lib/wamp/protocols/version_1.rb', line 17 def welcome(id) [type[:WELCOME], id, version, server_ident].to_json end |