nanoMMO 0.97.8
Building an MMO: The Engineering Series
Loading...
Searching...
No Matches
login_client.h
Go to the documentation of this file.
1#ifndef NANOMMO_PROTOCOL_LOGIN_CLIENT_H_
2#define NANOMMO_PROTOCOL_LOGIN_CLIENT_H_
3
4#include <chrono>
5#include <cstdint>
6#include <string>
7
8#include "absl/status/statusor.h"
9#include "asio/ssl/context.hpp"
10#include "protocol/nanommo.pb.h"
11
12namespace nanommo {
13
14/// How long a login waits for the login server's answer, once it has the
15/// server's address: connecting, shaking hands, asking and the reply. A login
16/// that takes longer is one a player's given up on. Looking the address up
17/// can take longer, as asio waits for the system's lookup to end.
18inline constexpr std::chrono::seconds kLoginDeadline{5};
19
20/// Sends the request to the login server over TLS, and waits for its reply,
21/// or returns why it couldn't: DeadlineExceeded when the reply didn't come
22/// within the deadline, as from a login server that's hung.
23absl::StatusOr<protocol::LoginReply> LogIn(
24 const std::string& host, uint16_t port, asio::ssl::context& tls,
25 const protocol::LoginRequest& request,
26 std::chrono::milliseconds deadline = kLoginDeadline);
27
28} // namespace nanommo
29
30#endif // NANOMMO_PROTOCOL_LOGIN_CLIENT_H_
Definition chat.cc:9
absl::StatusOr< protocol::LoginReply > LogIn(const std::string &host, uint16_t port, asio::ssl::context &tls, const protocol::LoginRequest &request, std::chrono::milliseconds deadline)
constexpr std::chrono::seconds kLoginDeadline