Class: TinyDTLS::Context
- Inherits:
-
Object
- Object
- TinyDTLS::Context
- Defined in:
- lib/tinydtls/context.rb
Overview
The class Context stores all per-connection information, it is exclusively used in the TinyDTLS::CONTEXT_MAP.
Instance Attribute Summary collapse
-
#queue ⇒ Object
readonly
The queue used for communication with the receive thread.
-
#secconf ⇒ Object
readonly
An instance of the security configuration class.
-
#sendfn ⇒ Object
readonly
The method used for sending data on the socket.
Class Method Summary collapse
-
.from_ptr(ptr) ⇒ Object
Create a new instance of this class from a pointer to a ‘struct dtls_context_t`.
Instance Method Summary collapse
-
#initialize(sendfn, queue, secconf) ⇒ Context
constructor
Create a new instance of this class with a given function to send message on the transport layer, a queue for storing received messages and a security configuration containing a key to identity mapping.
Constructor Details
#initialize(sendfn, queue, secconf) ⇒ Context
Create a new instance of this class with a given function to send message on the transport layer, a queue for storing received messages and a security configuration containing a key to identity mapping.
18 19 20 21 22 |
# File 'lib/tinydtls/context.rb', line 18 def initialize(sendfn, queue, secconf) @sendfn = sendfn @queue = queue @secconf = secconf end |
Instance Attribute Details
#queue ⇒ Object (readonly)
The queue used for communication with the receive thread.
9 10 11 |
# File 'lib/tinydtls/context.rb', line 9 def queue @queue end |
#secconf ⇒ Object (readonly)
An instance of the security configuration class.
12 13 14 |
# File 'lib/tinydtls/context.rb', line 12 def secconf @secconf end |
#sendfn ⇒ Object (readonly)
The method used for sending data on the socket.
6 7 8 |
# File 'lib/tinydtls/context.rb', line 6 def sendfn @sendfn end |
Class Method Details
.from_ptr(ptr) ⇒ Object
Create a new instance of this class from a pointer to a ‘struct dtls_context_t`. Such a pointer is, for instance, passed to the various tinydtls callback functions.
The ‘struct dtls_context_t` which the given pointer points to must have been created by TinyDTLS::UDPSocket#initialize.
30 31 32 33 |
# File 'lib/tinydtls/context.rb', line 30 def self.from_ptr(ptr) obj = Wrapper::DTLSContextStruct.new(ptr) return CONTEXT_MAP[Wrapper::dtls_get_app_data(obj).to_i] end |