Send a Create Party Request Message
Last updated on
Use the following function to send a party request message:
- C#
- Java
lobby.OnPartyCreateResponse = (PartyCreateResponse resp) =>
{
is_response_received = true;
//create party response
};
Task sendTask = lobby.SendPartyCreateRequest(new PartyCreateRequest()
{
Id = request_id
}, 0);
sendTask.Wait();
When you are finished, disconnect from the Lobby WebSocket service.
Task disconnectTask = lobby.Disconnect();
disconnectTask.Wait();
final String request_id = GenerateRandomId(64);
final CountDownLatch response = new CountDownLatch(1);
final StringBuilder responseMessage = new StringBuilder();
WebSocketListener listener = new WebSocketListener() {
@Override
public void onMessage(@NotNull WebSocket webSocket, @NotNull String text) {
if (response.getCount() > 0) {
responseMessage.append(text);
response.countDown();
}
}
};
OkhttpWebSocketClient ws = OkhttpWebSocketClient.create(
new DefaultConfigRepository(),
DefaultTokenRepository.getInstance(),
listener);
String requestMessage = PartyCreateRequest.builder()
.id(requestId)
.build()
.toWSM();
ws.sendMessage(requestMessage);
response.await(10, TimeUnit.SECONDS);