Store serial in server instance

The serial is needed for many server actions, but this is an
implementation detail, so the caller should not have to provide it on
every call.

Instead, store the serial in the server instance on server_start().

This paves the way to implement the "adb forward" fallback properly.
This commit is contained in:
Romain Vimont
2018-03-12 10:19:12 +01:00
parent 9e328ef98b
commit 2b3ed5bcdb
3 changed files with 21 additions and 14 deletions

View File

@@ -5,6 +5,7 @@
#include "net.h"
struct server {
const char *serial;
process_t process;
socket_t server_socket;
socket_t device_socket;
@@ -13,6 +14,7 @@ struct server {
};
#define SERVER_INITIALIZER { \
.serial = NULL, \
.process = PROCESS_NONE, \
.server_socket = INVALID_SOCKET, \
.device_socket = INVALID_SOCKET, \
@@ -28,10 +30,10 @@ SDL_bool server_start(struct server *server, const char *serial, Uint16 local_po
Uint16 max_size, Uint32 bit_rate);
// block until the communication with the server is established
socket_t server_connect_to(struct server *server, const char *serial, Uint32 timeout_ms);
socket_t server_connect_to(struct server *server, Uint32 timeout_ms);
// disconnect and kill the server process
void server_stop(struct server *server, const char *serial);
void server_stop(struct server *server);
// close and release sockets
void server_destroy(struct server *server);