The Handler represents points in time with HighResolutionTime, with microsecond resolution.
A HighResolutionTime is one of the following:
The two kinds of valid times behave the same way:
The difference between two local clock readings is taken on the monotonic clock directly, so it is not affected when the system clock is adjusted in between, manually or by NTP.
MessageInfo accompanies every message passed to a listener, and carries three times:
| Time | Meaning | Source |
|---|---|---|
| MessageInfo::requestTime | The gateway read the request this message answers from its TCP socket, RequestTime (5979). | Gateway, UTC. |
| MessageInfo::sendingTime | The gateway sent this message, SendingTime (52). | Gateway, UTC. |
| MessageInfo::receivingTime | The Handler started processing the data that contained this message. | Local monotonic clock. |
Responses carry both gateway times, notifications and broadcasts carry only the sending time, and other messages carry neither. A gateway time the message does not carry is UInt64NoValue in MessageInfo::rawRequestTime or MessageInfo::rawSendingTime. Check the raw field before calling MessageInfo::requestTime or [MessageInfo::sendingTime]: they do not recognize that value and return a meaningless time for it.
The Handler takes MessageInfo::receivingTime once for each block of data it reads from the socket, after the received-bytes listener has been invoked, and all messages decoded from that block share it.
The raw fields hold the values as received or measured: MessageInfo::rawRequestTime and MessageInfo::rawSendingTime are nanoseconds since the UNIX epoch, and MessageInfo::rawReceivingTime is a reading of the local clock in the platform's own units, described below.
Subtracting MessageInfo::receivingTime from HighResolutionTime::now gives the time a message spent in the Handler before reaching the listener. Both are local clock readings, so the result is exact to the clock's resolution. When several messages arrive in one block of data, the time of a later message also includes the processing of the earlier ones, their listener callbacks among them.
Subtracting MessageInfo::sendingTime from MessageInfo::receivingTime gives the time from the gateway to the Handler. The two times come from different clocks, so the result also includes the offset between the gateway's clock and the local system clock, and is only as accurate as the local clock's synchronization.