Add client open event for NetMarshalServer.
This commit is contained in:
parent
93b40d57a3
commit
1285317289
@ -583,7 +583,7 @@ public class NetMarshalClient implements Closeable {
|
|||||||
/**
|
/**
|
||||||
* Gets the {@link Consumer} closed consumer.
|
* Gets the {@link Consumer} closed consumer.
|
||||||
*
|
*
|
||||||
* @return The closed or null.
|
* @return The closed consumer or null.
|
||||||
*/
|
*/
|
||||||
public Consumer<NetMarshalClient> getClosedConsumer() {
|
public Consumer<NetMarshalClient> getClosedConsumer() {
|
||||||
return closedConsumer;
|
return closedConsumer;
|
||||||
|
@ -35,6 +35,7 @@ public class NetMarshalServer implements Closeable {
|
|||||||
protected BiConsumer<IPacket, NetMarshalClient> receiveBiConsumer;
|
protected BiConsumer<IPacket, NetMarshalClient> receiveBiConsumer;
|
||||||
protected BiConsumer<Exception, NetMarshalClient> receiveExceptionBiConsumer;
|
protected BiConsumer<Exception, NetMarshalClient> receiveExceptionBiConsumer;
|
||||||
protected BiConsumer<Exception, NetMarshalServer> acceptExceptionBiConsumer;
|
protected BiConsumer<Exception, NetMarshalServer> acceptExceptionBiConsumer;
|
||||||
|
protected Consumer<NetMarshalClient> openedConsumer;
|
||||||
protected Consumer<NetMarshalClient> closedConsumer;
|
protected Consumer<NetMarshalClient> closedConsumer;
|
||||||
protected BiConsumer<CandidateClient, NetMarshalServer> acceptanceBiConsumer;
|
protected BiConsumer<CandidateClient, NetMarshalServer> acceptanceBiConsumer;
|
||||||
protected BiConsumer<Socket, NetMarshalServer> socketSetupBiConsumer;
|
protected BiConsumer<Socket, NetMarshalServer> socketSetupBiConsumer;
|
||||||
@ -286,7 +287,7 @@ public class NetMarshalServer implements Closeable {
|
|||||||
/**
|
/**
|
||||||
* Gets the {@link Consumer} closed consumer.
|
* Gets the {@link Consumer} closed consumer.
|
||||||
*
|
*
|
||||||
* @return The closed or null.
|
* @return The closed consumer or null.
|
||||||
*/
|
*/
|
||||||
public Consumer<NetMarshalClient> getClosedConsumer() {
|
public Consumer<NetMarshalClient> getClosedConsumer() {
|
||||||
return closedConsumer;
|
return closedConsumer;
|
||||||
@ -303,6 +304,26 @@ public class NetMarshalServer implements Closeable {
|
|||||||
closedConsumer = consumer;
|
closedConsumer = consumer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link Consumer} opened consumer.
|
||||||
|
*
|
||||||
|
* @return The opened consumer or null.
|
||||||
|
*/
|
||||||
|
public Consumer<NetMarshalClient> getOpenedConsumer() {
|
||||||
|
return openedConsumer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the {@link Consumer} opened consumer.
|
||||||
|
*
|
||||||
|
* @param consumer The new opened consumer.
|
||||||
|
* @throws NullPointerException consumer is null.
|
||||||
|
*/
|
||||||
|
public void setOpenedConsumer(Consumer<NetMarshalClient> consumer) {
|
||||||
|
if (consumer == null) throw new NullPointerException("consumer is null");
|
||||||
|
openedConsumer = consumer;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link BiConsumer} client acceptance consumer.
|
* Gets the {@link BiConsumer} client acceptance consumer.
|
||||||
* Use {@link CandidateClient#accept} to declare whether the candidate should be accepted.
|
* Use {@link CandidateClient#accept} to declare whether the candidate should be accepted.
|
||||||
@ -418,6 +439,7 @@ public class NetMarshalServer implements Closeable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
found.open();
|
found.open();
|
||||||
|
if (openedConsumer != null) openedConsumer.accept(found);
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -485,6 +507,7 @@ public class NetMarshalServer implements Closeable {
|
|||||||
clients.add(client);
|
clients.add(client);
|
||||||
}
|
}
|
||||||
client.open();
|
client.open();
|
||||||
|
if (openedConsumer != null) openedConsumer.accept(client);
|
||||||
} else {
|
} else {
|
||||||
clientSocket.close();
|
clientSocket.close();
|
||||||
}
|
}
|
||||||
@ -527,6 +550,7 @@ public class NetMarshalServer implements Closeable {
|
|||||||
applyClientEvents(client);
|
applyClientEvents(client);
|
||||||
clients.add(client);
|
clients.add(client);
|
||||||
client.open();
|
client.open();
|
||||||
|
if (openedConsumer != null) openedConsumer.accept(client);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
synchronized (slockOutputs) {
|
synchronized (slockOutputs) {
|
||||||
|
Loading…
Reference in New Issue
Block a user