Browse Source

蓝牙调试中转服务端

lvjincheng 3 years ago
parent
commit
938faee667

+ 7 - 0
BluetoothServer/.classpath

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+	<classpathentry kind="lib" path="lib/JCEngine.jar"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

+ 17 - 0
BluetoothServer/.project

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>BluetoothServer</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

+ 11 - 0
BluetoothServer/.settings/org.eclipse.jdt.core.prefs

@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8

BIN
BluetoothServer/bin/Player.class


BIN
BluetoothServer/lib/JCEngine.jar


+ 40 - 0
BluetoothServer/src/Player.java

@@ -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);
+	}
+}