coapthon.layers package¶
Submodules¶
coapthon.layers.blocklayer module¶
- class coapthon.layers.blocklayer.BlockLayer[source]¶
Bases: object
Handle the Blockwise options. Hides all the exchange to both servers and clients.
- static error(transaction, code)[source]¶
Notifies generic error on blockwise exchange.
Parameters: transaction (Transaction) – the transaction that owns the response :rtype : Transaction :return: the edited transaction
- static incomplete(transaction)[source]¶
Notifies incomplete blockwise exchange.
Parameters: transaction (Transaction) – the transaction that owns the response :rtype : Transaction :return: the edited transaction
- receive_empty(empty, transaction)[source]¶
Dummy function. Used to do not broke the layered architecture.
Parameters: - empty (Message) – the received empty message
- transaction (Transaction) – the transaction that owns the empty message
:rtype : Transaction :return: the transaction
- receive_request(transaction)[source]¶
Handles the Blocks option in a incoming request.
Parameters: transaction (Transaction) – the transaction that owns the request :rtype : Transaction :return: the edited transaction
- receive_response(transaction)[source]¶
Handles the Blocks option in a incoming response.
Parameters: transaction (Transaction) – the transaction that owns the response :rtype : Transaction :return: the edited transaction
coapthon.layers.forwardLayer module¶
- class coapthon.layers.forwardLayer.ForwardLayer(server)[source]¶
Bases: object
Class used by Proxies to forward messages.
coapthon.layers.messagelayer module¶
- class coapthon.layers.messagelayer.MessageLayer(starting_mid)[source]¶
Bases: object
Handles matching between messages (Message ID) and request/response (Token)
- receive_empty(message)[source]¶
Pair ACKs with requests.
Parameters: message (Message) – the received message :rtype : Transaction :return: the transaction to which the message belongs to
- receive_request(request)[source]¶
Handle duplicates and store received messages.
Parameters: request (Request) – the incoming request :rtype : Transaction :return: the edited transaction
- receive_response(response)[source]¶
Pair responses with requests.
Parameters: response (Response) – the received response :rtype : Transaction :return: the transaction to which the response belongs to
- send_empty(transaction, related, message)[source]¶
Manage ACK or RST related to a transaction. Sets if the transaction has been acknowledged or rejected.
Parameters: - transaction – the transaction
- related – if the ACK/RST message is related to the request or the response. Must be equal to
transaction.request or to transaction.response or None :type message: Message :param message: the ACK or RST message to send
coapthon.layers.observelayer module¶
- class coapthon.layers.observelayer.ObserveLayer[source]¶
Bases: object
Manage the observing feature. It store observing relationships.
- notify(resource, root=None)[source]¶
Prepare notification for the resource to all interested observers.
Return type: list
Parameters: - resource – the resource for which send a new notification
- root – deprecated
Returns: the list of transactions to be notified
- receive_empty(empty, transaction)[source]¶
Manage the observe feature to remove a client in case of a RST message receveide in reply to a notification.
Parameters: - empty (Message) – the received message
- transaction (Transaction) – the transaction that owns the notification message
:rtype : Transaction :return: the modified transaction
- receive_request(transaction)[source]¶
Manage the observe option in the request end eventually initialize the client for adding to the list of observers or remove from the list.
Parameters: transaction (Transaction) – the transaction that owns the request :rtype : Transaction :return: the modified transaction
- receive_response(transaction)[source]¶
Sets notification’s parameters.
Parameters: transaction (Transaction) – the transaction :rtype : Transaction :return: the modified transaction
- remove_subscriber(message)[source]¶
Remove a subscriber based on token.
Parameters: message – the message
- send_empty(message)[source]¶
Eventually remove from the observer list in case of a RST message.
Parameters: message (Message) – the message Returns: the message unmodified
coapthon.layers.requestlayer module¶
- class coapthon.layers.requestlayer.RequestLayer(server)[source]¶
Bases: object
Class to handle the Request/Response layer
coapthon.layers.resourcelayer module¶
- class coapthon.layers.resourcelayer.ResourceLayer(parent)[source]¶
Bases: object
Handles the Resources.
- add_resource(transaction, parent_resource, lp)[source]¶
Render a POST on a new resource.
Parameters: - transaction – the transaction
- parent_resource – the parent of the resource
- lp – the location_path attribute of the resource
Returns: the response
- static corelinkformat(resource)[source]¶
Return a formatted string representation of the corelinkformat in the tree.
Returns: the string
- create_resource(path, transaction)[source]¶
Render a POST request.
Parameters: - path – the path of the request
- transaction – the transaction
Returns: the response
- delete_resource(transaction, path)[source]¶
Render a DELETE request.
Parameters: - transaction – the transaction
- path – the path
Returns: the response
- discover(transaction)[source]¶
Render a GET request to the .well-know/core link.
Parameters: transaction – the transaction Returns: the transaction
- edit_resource(transaction, path)[source]¶
Render a POST on an already created resource.
Parameters: - path – the path of the resource
- transaction – the transaction
Returns: the transaction