Class: CoRE::CoAP::Client
- Inherits:
-
Object
- Object
- CoRE::CoAP::Client
- Defined in:
- lib/core/coap/client.rb
Overview
CoAP client library
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#max_payload ⇒ Object
Returns the value of attribute max_payload.
-
#port ⇒ Object
Returns the value of attribute port.
Instance Method Summary collapse
-
#delete(*args) ⇒ Object
DELETE.
-
#delete_by_uri(uri, *args) ⇒ Object
DELETE by URI.
-
#get(*args) ⇒ Object
GET.
-
#get_by_uri(uri, *args) ⇒ Object
GET by URI.
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
-
#observe(path, host, port, callback, payload = nil, options = {}) ⇒ Object
OBSERVE.
-
#observe_by_uri(uri, *args) ⇒ Object
OBSERVE by URI.
-
#post(*args) ⇒ Object
POST.
-
#post_by_uri(uri, *args) ⇒ Object
POST by URI.
-
#put(*args) ⇒ Object
PUT.
-
#put_by_uri(uri, *args) ⇒ Object
PUT by URI.
-
#use_dtls ⇒ Object
Enable DTLS socket.
Constructor Details
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
7 8 9 |
# File 'lib/core/coap/client.rb', line 7 def host @host end |
#max_payload ⇒ Object
Returns the value of attribute max_payload.
7 8 9 |
# File 'lib/core/coap/client.rb', line 7 def max_payload @max_payload end |
#port ⇒ Object
Returns the value of attribute port.
7 8 9 |
# File 'lib/core/coap/client.rb', line 7 def port @port end |
Instance Method Details
#delete(*args) ⇒ Object
DELETE
114 115 116 |
# File 'lib/core/coap/client.rb', line 114 def delete(*args) client(:delete, *args) end |
#delete_by_uri(uri, *args) ⇒ Object
DELETE by URI
125 126 127 |
# File 'lib/core/coap/client.rb', line 125 def delete_by_uri(uri, *args) delete(*decode_uri(uri), *args) end |
#get(*args) ⇒ Object
GET
42 43 44 |
# File 'lib/core/coap/client.rb', line 42 def get(*args) client(:get, *args) end |
#get_by_uri(uri, *args) ⇒ Object
GET by URI
53 54 55 |
# File 'lib/core/coap/client.rb', line 53 def get_by_uri(uri, *args) get(*decode_uri(uri), *args) end |
#observe(path, host, port, callback, payload = nil, options = {}) ⇒ Object
OBSERVE
140 141 142 143 |
# File 'lib/core/coap/client.rb', line 140 def observe(path, host, port, callback, payload = nil, = {}) [:observe] = 0 client(:get, path, host, port, payload, , callback) end |
#observe_by_uri(uri, *args) ⇒ Object
OBSERVE by URI
154 155 156 |
# File 'lib/core/coap/client.rb', line 154 def observe_by_uri(uri, *args) observe(*decode_uri(uri), *args) end |
#post(*args) ⇒ Object
POST
66 67 68 |
# File 'lib/core/coap/client.rb', line 66 def post(*args) client(:post, *args) end |
#post_by_uri(uri, *args) ⇒ Object
POST by URI
77 78 79 |
# File 'lib/core/coap/client.rb', line 77 def post_by_uri(uri, *args) post(*decode_uri(uri), *args) end |
#put(*args) ⇒ Object
PUT
90 91 92 |
# File 'lib/core/coap/client.rb', line 90 def put(*args) client(:put, *args) end |
#put_by_uri(uri, *args) ⇒ Object
PUT by URI
101 102 103 |
# File 'lib/core/coap/client.rb', line 101 def put_by_uri(uri, *args) put(*decode_uri(uri), *args) end |
#use_dtls ⇒ Object
Enable DTLS socket.
27 28 29 30 31 |
# File 'lib/core/coap/client.rb', line 27 def use_dtls require 'CoDTLS' @options[:socket] = CoDTLS::SecureSocket self end |