mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
[FEATURE] Система уведомлений
This commit is contained in:
parent
641001f041
commit
490ba360e7
5 changed files with 52 additions and 26 deletions
|
@ -84,7 +84,7 @@ public static void registerCommands(pro.gravit.utils.command.CommandHandler hand
|
|||
service.registerCommand("serverStatus", new ServerStatusCommand(server));
|
||||
service.registerCommand("checkInstall", new CheckInstallCommand(server));
|
||||
service.registerCommand("multi", new MultiCommand(server));
|
||||
service.registerCommand("getModulus", new GetModulusCommand(server));
|
||||
service.registerCommand("notify", new NotifyCommand(server));
|
||||
service.registerCommand("component", new ComponentCommand(server));
|
||||
service.registerCommand("givePermission", new GivePermissionsCommand(server));
|
||||
service.registerCommand("getPermissions", new GetPermissionsCommand(server));
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
package pro.gravit.launchserver.command.service;
|
||||
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.command.Command;
|
||||
|
||||
public class GetModulusCommand extends Command {
|
||||
public GetModulusCommand(LaunchServer server) {
|
||||
super(server);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getArgsDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsageDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(String... args) {
|
||||
//LogHelper.info("You publickey modulus: %s", server.publicKey.getModulus().toString(16));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package pro.gravit.launchserver.command.service;
|
||||
|
||||
import pro.gravit.launcher.events.NotificationEvent;
|
||||
import pro.gravit.launcher.request.WebSocketEvent;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.command.Command;
|
||||
import pro.gravit.launchserver.socket.WebSocketService;
|
||||
|
||||
public class NotifyCommand extends Command {
|
||||
public NotifyCommand(LaunchServer server) {
|
||||
super(server);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getArgsDescription() {
|
||||
return "[head] [message]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsageDescription() {
|
||||
return "send notification to all connected client";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(String... args) throws Exception {
|
||||
verifyArgs(args, 2);
|
||||
NotificationEvent event = new NotificationEvent(args[0], args[1]);
|
||||
WebSocketService service = server.nettyServerSocketHandler.nettyServer.service;
|
||||
service.sendObjectAll(event, WebSocketEvent.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package pro.gravit.launcher.events;
|
||||
|
||||
import pro.gravit.launcher.request.WebSocketEvent;
|
||||
|
||||
public class NotificationEvent implements WebSocketEvent {
|
||||
public final String head;
|
||||
public final String message;
|
||||
|
||||
public NotificationEvent(String head, String message) {
|
||||
this.head = head;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "notification";
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@
|
|||
import com.google.gson.GsonBuilder;
|
||||
import pro.gravit.launcher.Launcher;
|
||||
import pro.gravit.launcher.events.ExceptionEvent;
|
||||
import pro.gravit.launcher.events.NotificationEvent;
|
||||
import pro.gravit.launcher.events.request.*;
|
||||
import pro.gravit.launcher.hasher.HashedEntry;
|
||||
import pro.gravit.launcher.hasher.HashedEntryAdapter;
|
||||
|
@ -107,6 +108,7 @@ public void registerResults() {
|
|||
results.register("exception", ExceptionEvent.class);
|
||||
results.register("register", RegisterRequestEvent.class);
|
||||
results.register("setpassword", SetPasswordRequestEvent.class);
|
||||
results.register("notification", NotificationEvent.class);
|
||||
}
|
||||
|
||||
public void registerHandler(EventHandler eventHandler) {
|
||||
|
|
Loading…
Reference in a new issue