Bases: object
Process network activity related to CoAP messages on this end-point.
This method is responsible for transmitting (and re-transmitting) outgoing messages, and for receiving incoming messages. It will block until the timeout is reached, or an incoming message is received.
Incoming messages that are transaction responses are, if possible, associated with the transmission record to which they pertain. A ReceptionRecord is returned. The infrastructure does not automatically acknowledge any incoming message; this is an application responsibility.
Parameter: | timeout_ms – The maximum time, in milliseconds, that this method should block. A value of None indicates no limit: the method will block forever if no activity occurs. |
---|---|
Returns: | rx_record or None |
Return type: | ReceptionRecord |
Register the given socket as a potential source of incoming messages.
The primary socket is automatically registered. This method can be used to associate additional sockets, such as multicast ones, with this end-point.
Note: | Regardless of the socket on which a message is received, any response will be transmitted from socket. |
---|
Transmit a message to the remote.
The message should have a code of either Message.CON or Message.NON; acknowledgements and resets should be generated through the ReceptionRecord methods.
The TransmissionRecord associated with the transmission is returned.
Note: | Invoking this does not actually transmit the message: it merely records it and queues it for transmission on the next invocation of process(). |
---|
Return a reference to the primary socket associated with the end-point.
If this end-point is expected to receive REST requests, the socket should be bound to a known port so that clients can identify the server.
Bases: object
Represent the components of a CoAP message.
The transaction ID is not recorded in the message instance. Rather, it is recorded in a TransmissionRecord or ReceptionRecord.
Create a Message instance.
As a convenience, message options can be created from keyword parameters if the keywords are present in OptionKeywords.
Parameters: |
|
---|
A map from Python identifiers to option classes.
These identifiers can be provided as keyword parameters to the Message.__init__() method; the corresponding option class will be invoked with the parameter value to create an option that is associated with the message.
Add a new option instance.
If the option can appear multiple times, this method is intended to add the new value to the existing ones.
Warning: | Currently multi-valued options are not supported and this is equivalent to replaceOption(). |
---|
Create a Message instance from a payload.
This method decodes the payload, and returns a pair (xid, message) where xid is the transaction ID extracted from the encoded message, and message is an instance of Message initialized to the decoded components of the data.
Parameter: | payload – A sequence of octets comprising a complete CoAP packet |
---|---|
Return type: | (int, Message) |
Remove the option from the message.
Parameter: | opt – An option, specified as an option instance, an option class, or the type code of an option. |
---|
Locate the given option within the message.
Returns None if no matching option can be found.
Parameter: | opt – An option, specified as an option instance, an option class, or the type code of an option. |
---|
A tuple containing the options associated with the message.
The options are sorted in increasing value of option type.
The payload of the message as a str.
If this is not an empty string, there should be a corresponding coapy.options.ContentType option present that defines its format (if the default value of text/plain is not appropriate).
Add a new option instance.
If the option is already present in message, its previous value is replaced by the new one.
Return the transaction type (one of CON, NON, ACK, RST).
Note: | The transaction type is assigned when the message is created, and cannot be changed thereafter. |
---|
Bases: object
Material related to a received CoAP message.
The TransmissionRecord to which the received message was interpreted as a response.
The value will be None if the message transaction type is neither Message.ACK nor Message.RST, or if the receiving EndPoint could not identify the relevant message (e.g., it had already been expired from the transmission cache).
Bases: object
Material related to a transmitted CoAP message.
Parameters: |
---|
The time.time() at which the last event related to the transmission occured.
Transmission events are:
A reference to the Message from which the transmission derived.
Note: | The content of the message may have been changed by application code subsequent to its transmission. |
---|
Get the time.time() value at which the next event associated with this transmission is due.
Predictable transmission events are:
Returns None if there are no events associated with the transmission.
Return the number of (re-)transmissions yet to occur.
A positive value requires that next_event_time not be None.
Return True iff address is a multicast address.
This function is used to eliminate retransmissions for confirmable messages sent to multicast addresses.
Parameter: | address – A socket address as supported by the Python socket functions: i.e. a pair (host, port) for IPv4 addresses and a tuple (host, port, flowinfo, scopeid) for IPv6. The host may be either a host name or an IP address in the textual notation appropriate to the address family. |
---|