class TinyDTLS::Context
The class Context
stores all per-connection information, it is exclusively used in the `TinyDTLS::CONTEXT_MAP`.
Attributes
The queue used for communication with the receive thread.
An instance of the security configuration class.
The method used for sending data on the socket.
Public Class Methods
Retrieves an instance of this class from the TinyDTLS::CONTEXT_MAP using 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.
# File lib/tinydtls/context.rb, line 33 def self.from_ptr(ptr) obj = Wrapper::DTLSContextStruct.new(ptr) return CONTEXT_MAP[Wrapper::dtls_get_app_data(obj).to_i] end
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.
# File lib/tinydtls/context.rb, line 18 def initialize(sendfn, queue, secconf) @sendfn = sendfn @queue = queue @secconf = secconf @ffi_struct = Wrapper::DTLSContextStruct.new( Wrapper::dtls_new_context(FFI::Pointer.new(key))) end
Public Instance Methods
Returns a key which should be used to store this context in the global TinyDTLS::CONTEXT_MAP.
# File lib/tinydtls/context.rb, line 40 def key object_id end
Returns an FFI::Struct for this object, representing the underlying `dtls_context_t`.
# File lib/tinydtls/context.rb, line 46 def to_ffi @ffi_struct end