@startuml
skinparam roundcorner 20
skinparam sequenceMessageAlign direction
hide footbox

actor           User                    as usr                      order 1

box "CoAPthon"
queue           HelperClient.queue                  <<atribut>>     order 19
participant     HelperClient.get                    <<methode>>     order 10
participant     HelperClient.send_request           <<methode>>     order 11

participant     CoapClient.send_message             <<methode>>     order 21
participant     CoapClient.send_datagram            <<methode>>     order 22
participant     CoapClient._start_retransmission    <<thread>>      order 31
participant     CoapClient._receiver_thread         <<thread>>      order 32
participant     CoapClient._retransmit              <<thread>>      order 33

end box

box "Module IA"
participant     SuperviseurLocal.RTO                <<atribut>>     order 41
participant     SuperviseurLocal.envoie_token       <<methode>>     order 42
participant     SuperviseurLocal.reception_token    <<methode>>     order 43
end box
boundary        reseau                                              order 51

usr -> HelperClient.get ++: get(path)
HelperClient.get -> HelperClient.get : generate_random_token(2)
HelperClient.get -> HelperClient.send_request ++: send_request(request)
HelperClient.send_request -> CoapClient.send_message ++: send_message(request)
CoapClient.send_message -> CoapClient.send_datagram ++: send_datagram(request)

CoapClient.send_datagram -> reseau : datagram
CoapClient.send_datagram -> SuperviseurLocal.envoie_token : envoie(token)
CoapClient.send_datagram -> CoapClient._receiver_thread ++#red: Thread.start()

CoapClient.send_datagram --> CoapClient.send_message --: None
CoapClient.send_message -> CoapClient._start_retransmission ++#Blue: Thread.start()
CoapClient.send_message --> HelperClient.send_request --: None
HelperClient.send_request -> HelperClient.queue : wait for

CoapClient._start_retransmission -> SuperviseurLocal.RTO ++#Blue: RTO ?
return RTO

CoapClient._start_retransmission -> CoapClient._retransmit --++#Green: Thread.start()

loop Pas de réponse sur le socket UDP avant l'expiration du RTO
...Attente...
CoapClient._retransmit -> CoapClient._retransmit : retransmit_count += 1
CoapClient._retransmit -> CoapClient._retransmit : RTO *= 2
CoapClient._retransmit -> CoapClient.send_datagram ++#Green: send_datagram(request) 
CoapClient.send_datagram -> reseau : datagram
CoapClient.send_datagram -> SuperviseurLocal.envoie_token : envoie(token)
return None
end

reseau --> CoapClient._receiver_thread : datagram
CoapClient._receiver_thread -> SuperviseurLocal.reception_token : reception(token)
CoapClient._receiver_thread -> CoapClient._retransmit !!: wait for the thread end
CoapClient._receiver_thread -> HelperClient.queue --: response

HelperClient.queue --> HelperClient.send_request : response
HelperClient.send_request --> HelperClient.get --: response
HelperClient.get --> usr --: response

@enduml