|
18 | 18 | import java.net.UnknownHostException; |
19 | 19 | import java.nio.charset.StandardCharsets; |
20 | 20 | import java.util.Arrays; |
| 21 | +import java.util.List; |
21 | 22 | import java.util.Objects; |
22 | 23 | import java.util.concurrent.atomic.AtomicBoolean; |
23 | 24 | import java.util.concurrent.atomic.AtomicLong; |
@@ -234,32 +235,35 @@ public static void setWaiting() { |
234 | 235 | /** |
235 | 236 | * <p>Set Terracotta Android into 'host-scanning' state.</p> |
236 | 237 | * |
237 | | - * @param player the player's name. A default value will be taken if it's null. |
| 238 | + * @param room the room code, which may be used if it's valid. |
| 239 | + * @param player the player's name. A default value will be taken if it's null. |
| 240 | + * @param extraNodes extra public server nodes for EasyTier. |
238 | 241 | * @throws IllegalStateException if Terracotta Android hasn't been initialized. |
239 | 242 | * @implNote Usually, this method doesn't take a long time to fetch states. |
240 | 243 | * However, when initializing the EasyTier, state fetching may block for ~1 seconds. |
241 | 244 | */ |
242 | | - public static void setScanning(@Nullable String room, @Nullable String player) { |
| 245 | + public static void setScanning(@Nullable String room, @Nullable String player, @Nullable List<String> extraNodes) { |
243 | 246 | assertStarted(); |
244 | | - setScanning0(room, player); |
| 247 | + setScanning0(room, playerm, extraNodes == null ? null : String.join("\0", extraNodes)); |
245 | 248 | } |
246 | 249 |
|
247 | 250 | /** |
248 | 251 | * <p>Set Terracotta Android into 'guest-connecting' state.</p> |
249 | 252 | * |
250 | | - * @param room the room code. False will be returned if it's invalid. |
251 | | - * @param player the player's name. A default value will be taken if it's null. |
| 253 | + * @param room the room code. False will be returned if it's invalid. |
| 254 | + * @param player the player's name. A default value will be taken if it's null. |
| 255 | + * @param extraNodes extra public server nodes for EasyTier. |
252 | 256 | * @return True if room code is valid, false otherwise. |
253 | 257 | * @throws IllegalStateException if Terracotta Android hasn't been initialized. |
254 | 258 | * @throws NullPointerException if room is null. |
255 | 259 | * @implNote Usually, this method doesn't take a long time to fetch states. |
256 | 260 | * However, when initializing the EasyTier, state fetching may block for ~1 seconds. |
257 | 261 | */ |
258 | | - public static boolean setGuesting(String room, @Nullable String player) { |
| 262 | + public static boolean setGuesting(String room, @Nullable String player, @Nullable List<String> extraNodes) { |
259 | 263 | Objects.requireNonNull(room, "room"); |
260 | 264 |
|
261 | 265 | assertStarted(); |
262 | | - return setGuesting0(room, player); |
| 266 | + return setGuesting0(room, player, extraNodes == null ? null : String.join("\0", extraNodes)); |
263 | 267 | } |
264 | 268 |
|
265 | 269 | /** |
@@ -381,7 +385,7 @@ public static void panic() { |
381 | 385 |
|
382 | 386 | private static final long FD_PENDING = ((long) Integer.MAX_VALUE) + 1; |
383 | 387 | private static final long FD_REJECT = FD_PENDING + 1; |
384 | | -; |
| 388 | + |
385 | 389 | @SuppressWarnings("unused") // Native callback |
386 | 390 | private static int onVpnServiceStateChanged(byte ip1, byte ip2, byte ip3, byte ip4, short network_length, String cidr) throws UnknownHostException { |
387 | 391 | if (pendingRequest != null) { |
@@ -460,9 +464,9 @@ private static void assertStarted() { |
460 | 464 |
|
461 | 465 | private static native void setWaiting0(); |
462 | 466 |
|
463 | | - private static native void setScanning0(String room, String player); |
| 467 | + private static native void setScanning0(String room, String player, String extraNodes); |
464 | 468 |
|
465 | | - private static native boolean setGuesting0(String room, String player); |
| 469 | + private static native boolean setGuesting0(String room, String player, String extraNodes); |
466 | 470 |
|
467 | 471 | private static native int verifyRoomCode0(String room); |
468 | 472 |
|
|
0 commit comments