| 110 | } |
| 111 | |
| 112 | bool ENetDriver::Connect() |
| 113 | { |
| 114 | LOG(Info, "Connecting using ENet..."); |
| 115 | |
| 116 | ENetAddress address = { 0 }; |
| 117 | address.port = _config.Port; |
| 118 | enet_address_set_host(&address, _config.Address.ToStringAnsi().GetText()); |
| 119 | |
| 120 | // Create ENet host |
| 121 | _host = enet_host_create(nullptr, 1, 1, 0, 0); |
| 122 | if (_host == nullptr) |
| 123 | { |
| 124 | LOG(Error, "Failed to initialize ENet host!"); |
| 125 | return false; |
| 126 | } |
| 127 | |
| 128 | // Create ENet peer/connect to the server |
| 129 | _peer = enet_host_connect(_host, &address, 1, 0); |
| 130 | if (_peer == nullptr) |
| 131 | { |
| 132 | LOG(Error, "Failed to create ENet host!"); |
| 133 | enet_host_destroy(_host); |
| 134 | return false; |
| 135 | } |
| 136 | |
| 137 | return true; |
| 138 | } |
| 139 | |
| 140 | void ENetDriver::Disconnect() |
| 141 | { |
nothing calls this directly
no test coverage detected