Skip to content

Commit

Permalink
Wait for state change
Browse files Browse the repository at this point in the history
  • Loading branch information
Mindgamesnl committed May 5, 2024
1 parent d476f1d commit 641f43b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import com.craftmend.openaudiomc.generic.commands.interfaces.SubCommand;
import com.craftmend.openaudiomc.generic.environment.MagicValue;
import com.craftmend.openaudiomc.generic.platform.interfaces.TaskService;
import com.craftmend.openaudiomc.generic.user.User;
import com.craftmend.openaudiomc.generic.storage.interfaces.Configuration;
import com.craftmend.openaudiomc.generic.storage.enums.StorageKey;
Expand All @@ -27,7 +28,7 @@ public void onExecute(User sender, String[] args) {

sender.sendMessage(MagicValue.COMMAND_PREFIX.get(String.class) + "Welcome to OpenAudioMc! you accepted the terms, enjoy the service!");

service.connectIfDown();
OpenAudioMc.resolveDependency(TaskService.class).runAsync(() -> service.connectIfDown());

for (ClientConnection client : service.getClients()) {
client.getAuth().publishSessionUrl();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.craftmend.openaudiomc.generic.commands.objects.Argument;
import com.craftmend.openaudiomc.generic.networking.interfaces.NetworkingService;
import com.craftmend.openaudiomc.generic.platform.OaColor;
import com.craftmend.openaudiomc.generic.platform.interfaces.TaskService;
import com.craftmend.openaudiomc.generic.rest.RestRequest;
import com.craftmend.openaudiomc.generic.rest.routes.Endpoint;
import com.craftmend.openaudiomc.generic.rest.types.ClaimCodeResponse;
Expand All @@ -28,7 +29,7 @@ public void onExecute(User sender, String[] args) {
}

// init connection so we receive the event
OpenAudioMc.getService(NetworkingService.class).connectIfDown();
OpenAudioMc.resolveDependency(TaskService.class).runAsync(() -> OpenAudioMc.getService(NetworkingService.class).connectIfDown());

message(sender, OaColor.GRAY + "Generating link...");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.craftmend.openaudiomc.generic.client.objects.ClientConnection;
import com.craftmend.openaudiomc.generic.networking.interfaces.NetworkingService;
import com.craftmend.openaudiomc.generic.platform.Platform;
import com.craftmend.openaudiomc.generic.platform.interfaces.TaskService;
import com.craftmend.openaudiomc.generic.user.User;

public class ReloadSubCommand extends SubCommand {
Expand All @@ -33,7 +34,7 @@ public void onExecute(User sender, String[] args) {
OpenAudioMc.getService(NetworkingService.class).stop();

message(sender, Platform.makeColor("RED") + "Re-activating account...");
OpenAudioMc.getService(NetworkingService.class).connectIfDown();
OpenAudioMc.resolveDependency(TaskService.class).runAsync(() -> OpenAudioMc.getService(NetworkingService.class).connectIfDown());

EventApi.getInstance().callEvent(new SystemReloadEvent());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void connectIfDown() {
}
// update state
OpenAudioMc.getService(OpenaudioAccountService.class).startVoiceHandshake();
OpenAudioMc.resolveDependency(TaskService.class).runAsync(() -> socketConnection.setupConnection());
socketConnection.setupConnection();
} finally {
connectLock.unlock();
}
Expand Down

0 comments on commit 641f43b

Please sign in to comment.