|
|
@@ -0,0 +1,40 @@
|
|
|
+import io.netty.util.internal.ConcurrentSet;
|
|
|
+import pers.jc.engine.JCEngine;
|
|
|
+import pers.jc.engine.JCEntity;
|
|
|
+import pers.jc.network.SocketFunction;
|
|
|
+import pers.jc.util.JCLogger;
|
|
|
+
|
|
|
+@SuppressWarnings("deprecation")
|
|
|
+public class Player extends JCEntity {
|
|
|
+ public static ConcurrentSet<Player> players = new ConcurrentSet<>();
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ JCEngine.boot(9888, "/BLE", Player.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onLoad() {
|
|
|
+ players.add(this);
|
|
|
+ System.out.println("怬 ID:" + id);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onDestroy() {
|
|
|
+ players.remove(this);
|
|
|
+ System.out.println("Í˳ö ID:" + id);
|
|
|
+ }
|
|
|
+
|
|
|
+ @SocketFunction
|
|
|
+ public void uploadData(String sign, String data) {
|
|
|
+ for (Player player : players) {
|
|
|
+ if (player != this) {
|
|
|
+ player.call("receiveData", sign, data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @SocketFunction
|
|
|
+ public void showError(String error) {
|
|
|
+ JCLogger.error("[Error From Client]", error);
|
|
|
+ }
|
|
|
+}
|