| 49 | } |
| 50 | |
| 51 | void onMessage(const TcpConnectionPtr& conn, Buffer* buf, Timestamp receiveTime) |
| 52 | { |
| 53 | if (buf->readableBytes() >= sizeof(int32_t)) |
| 54 | { |
| 55 | const void* data = buf->peek(); |
| 56 | int32_t be32 = *static_cast<const int32_t*>(data); |
| 57 | buf->retrieve(sizeof(int32_t)); |
| 58 | time_t time = sockets::networkToHost32(be32); |
| 59 | Timestamp ts(implicit_cast<uint64_t>(time) * Timestamp::kMicroSecondsPerSecond); |
| 60 | LOG_INFO << "Server time = " << time << ", " << ts.toFormattedString(); |
| 61 | } |
| 62 | else |
| 63 | { |
| 64 | LOG_INFO << conn->name() << " no enough data " << buf->readableBytes() |
| 65 | << " at " << receiveTime.toFormattedString(); |
| 66 | } |
| 67 | } |
| 68 | }; |
| 69 | |
| 70 | int main(int argc, char* argv[]) |
nothing calls this directly
no test coverage detected