-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix reconnect, add say and kick to server, add cors
- Loading branch information
1 parent
fbda1b5
commit 7e7866d
Showing
12 changed files
with
139 additions
and
43 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import 'package:consoler/consoler.dart'; | ||
import 'package:quokka_server/main.dart'; | ||
|
||
class PlayersProgram extends ConsoleProgram { | ||
final QuokkaServer server; | ||
|
||
PlayersProgram(this.server); | ||
|
||
@override | ||
String getDescription() => "Kick a player"; | ||
|
||
@override | ||
String getUsage() => 'kick <ID>'; | ||
|
||
@override | ||
void run(String label, List<String> args) { | ||
if (args.length != 1) { | ||
server.log("Wrong usage, use ${getUsage()}", level: LogLevel.error); | ||
} | ||
final arg = int.tryParse(args[0]); | ||
if (arg == null) { | ||
server.log("ID should be a number", level: LogLevel.error); | ||
return; | ||
} | ||
final result = server.kick(arg); | ||
if (result) { | ||
server.log("$arg successfully kicked.", level: LogLevel.info); | ||
} else { | ||
server.log("$arg could not be kicked.", level: LogLevel.error); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import 'package:consoler/consoler.dart'; | ||
import 'package:quokka_api/quokka_api.dart'; | ||
import 'package:quokka_server/main.dart'; | ||
|
||
class SayProgram extends ConsoleProgram { | ||
final QuokkaServer server; | ||
|
||
SayProgram(this.server); | ||
@override | ||
String getDescription() => "Send a message in the message"; | ||
|
||
@override | ||
Future<void> run(String label, List<String> args) async { | ||
final message = args.join(' '); | ||
server.process(MessageRequest(message)); | ||
} | ||
} |