This initialisation is executed when the users chooses to run as a server
| 102 | // This initialisation is executed when the users chooses |
| 103 | // to run as a server |
| 104 | void server() { |
| 105 | |
| 106 | // Randomly create a new identity for our link example |
| 107 | RNS::Identity server_identity = RNS::Identity(); |
| 108 | |
| 109 | // We create a destination that clients can connect to. We |
| 110 | // want clients to create links to this destination, so we |
| 111 | // need to create a "single" destination type. |
| 112 | RNS::Destination server_destination = RNS::Destination( |
| 113 | server_identity, |
| 114 | RNS::Type::Destination::IN, |
| 115 | RNS::Type::Destination::SINGLE, |
| 116 | APP_NAME, |
| 117 | "linkexample" |
| 118 | ); |
| 119 | |
| 120 | // We configure a function that will get called every time |
| 121 | // a new client creates a link to this destination. |
| 122 | server_destination.set_link_established_callback(client_connected); |
| 123 | |
| 124 | // Everything's ready! |
| 125 | // Let's Wait for client requests or user input |
| 126 | server_loop(server_destination); |
| 127 | } |
| 128 | |
| 129 | |
| 130 | /* |
no test coverage detected