| 69 | } |
| 70 | |
| 71 | int ExternalClients::init_client_connection(const string& host, int portnum, |
| 72 | int my_client_id) |
| 73 | { |
| 74 | ScopeLock _(lock); |
| 75 | int plain_socket; |
| 76 | set_up_client_socket(plain_socket, host.c_str(), portnum); |
| 77 | octetStream(to_string(my_client_id)).Send(plain_socket); |
| 78 | string my_client_name = "C" + to_string(my_client_id); |
| 79 | if (peer_ctxs.find(my_client_id) == peer_ctxs.end()) |
| 80 | peer_ctxs[my_client_id] = new client_ctx(my_client_name); |
| 81 | auto socket = new client_socket(io_service, *peer_ctxs[my_client_id], |
| 82 | plain_socket, "P" + to_string(party_num), "C" + to_string(my_client_id), |
| 83 | true); |
| 84 | { |
| 85 | octetStream specification; |
| 86 | specification.Receive(socket); |
| 87 | } |
| 88 | int id = -1; |
| 89 | if (not external_client_sockets.empty()) |
| 90 | id = min(id, external_client_sockets.begin()->first); |
| 91 | external_client_sockets[id] = socket; |
| 92 | return id; |
| 93 | } |
| 94 | |
| 95 | void ExternalClients::close_connection(int client_id) |
| 96 | { |
no test coverage detected