Created
October 4, 2013 09:46
-
-
Save daschl/6823538 to your computer and use it in GitHub Desktop.
connecting attempt. not only return it to the user, but also react on changes in an async manner.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Handle {@link ConnectRequest} messages. | |
* | |
* @param request the connect request message. | |
* @return a {@link ConnectResponse}. | |
*/ | |
private Promise<ConnectResponse> handleConnect(ConnectRequest request) { | |
if (connected.get()) { | |
return Promises.success(ConnectResponse.alreadyConnected()).get(); | |
} else { | |
Promise<ConnectResponse> connectPromise = configProvider.connect(request); | |
connectPromise.onSuccess(new Consumer<ConnectResponse>() { | |
@Override | |
public void accept(ConnectResponse connectResponse) { | |
connected.set(true); | |
} | |
}); | |
return connectPromise; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment