我是很新的,我只是想创建一个简单的websocket没有任何其他使用com.github.czyzby.websocket.WebSocket;
这是我的html laucher:
@Override
public GwtApplicationConfiguration getConfig () {
// Resizable application, uses available space in browser
return new GwtApplicationConfiguration(true);
}
@Override
public ApplicationListener createApplicationListener () {
GwtWebSockets.initiate();
return new GameClass();
}
我GameClass:
public class GameClass extends Game {
public GameClass() {
super();
}
@Override
public void create() {
WebSocket socket = WebSockets.newSocket(WebSockets.toWebSocketUrl("localHost", 8080));
socket.setSendGracefully(true);
socket.addListener(new WebSocketListener() {
@Override
public boolean onOpen(WebSocket webSocket) {
System.out.println("Opened!");
return false;
}
@Override
public boolean onClose(WebSocket webSocket, WebSocketCloseCode code, String reason) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean onMessage(WebSocket webSocket, String packet) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean onMessage(WebSocket webSocket, byte[] packet) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean onError(WebSocket webSocket, Throwable error) {
// TODO Auto-generated method stub
return false;
}
});
}
@Override
public void render() {
}
我build.gradle
buildscript {
repositories {
google()
mavenLocal()
mavenCentral()
gradlePluginPortal()
maven { url 'https://plugins.gradle.org/m2/' }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
dependencies {
classpath 'org.wisepersist:gwt-gradle-plugin:1.1.16'
classpath 'org.gretty:gretty:3.0.7'
}
}
allprojects {
apply plugin: "eclipse"
version = '1.0'
group = 'com.github.MrStahlfelge.gdx-websockets'
ext {
appName = "my-gdx-game"
gdxVersion = '1.10.0'
roboVMVersion = '2.3.15'
box2DLightsVersion = '1.5'
ashleyVersion = '1.7.4'
aiVersion = '1.8.2'
gdxControllersVersion = '2.2.1'
}
repositories {
mavenLocal()
mavenCentral()
google()
gradlePluginPortal()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
maven { url "https://jitpack.io" }
}
}
project(":desktop") {
apply plugin: "java-library"
dependencies {
implementation project(":core")
api "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"
api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
api "de.golfgl.gdxgamesvcs:gdx-gamesvcs-core-gamejolt:1.1.0"
api "de.tomgrill.gdxdialogs:gdx-dialogs-desktop:1.3.0"
api "com.github.MrStahlfelge.gdx-websockets:common:1.1.0"
}
}
project(":html") {
apply plugin: "java-library"
apply plugin: "gwt"
apply plugin: "war"
apply plugin: "org.gretty"
dependencies {
implementation project(":core")
api "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
api "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
api "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
api "de.golfgl.gdxgamesvcs:gdx-gamesvcs-core:1.1.0:sources"
api "de.golfgl.gdxgamesvcs:gdx-gamesvcs-core-gamejolt:1.1.0:sources"
api "de.tomgrill.gdxdialogs:gdx-dialogs-html:1.3.0"
api "de.tomgrill.gdxdialogs:gdx-dialogs-html:1.3.0:sources"
api "de.tomgrill.gdxdialogs:gdx-dialogs-core:1.3.0:sources"
api "com.github.MrStahlfelge.gdx-websockets:core:1.1.0:sources"
api "com.github.MrStahlfelge.gdx-websockets:html:1.1.0"
api "com.github.MrStahlfelge.gdx-websockets:html:1.1.0:sources"
api "com.github.tommyettinger:jbump:1.0.1:sources"
api "com.kotcrab.vis:vis-ui:1.4.11:sources"
}
}
project(":core") {
apply plugin: "java-library"
dependencies {
api "com.badlogicgames.gdx:gdx:$gdxVersion"
api "de.golfgl.gdxgamesvcs:gdx-gamesvcs-core:1.1.0"
api "de.tomgrill.gdxdialogs:gdx-dialogs-core:1.3.0"
api "com.github.MrStahlfelge.gdx-websockets:core:1.1.0"
api "com.github.tommyettinger:jbump:1.0.1"
api "com.kotcrab.vis:vis-ui:1.4.11"
api "com.esotericsoftware.spine:spine-libgdx:3.8.55.1"
}
}
}
当我在桌面上运行时一切正常,但是当我运行superdev或dist时,出现以下错误:
Task:core:compileJava FAILED
FAILURE: Build failed with a exception.
- 哪里出错了:任务':core:compileJava'执行失败。
无法解析配置':core:compileClasspath'的所有文件。无法找到com.github.MrStahlfelge.gdx-websockets:core:1.1.0。可在以下地点搜索:- file:/C:/用户/用户/.m2/仓库/com/github/MrStahlfelge/gdx-websockets/core/1.1.0/core-1.1.0.pom——https://repo.maven.apache.org/maven2/com/github/MrStahlfelge/gdx-websockets/core/1.1.0/core-1.1.0.pom——https://dl.google.com/dl/android/maven2/com/github/MrStahlfelge/gdx-websockets/core/1.1.0/core-1.1.0.pom——https://plugins.gradle.org/m2/com/github/MrStahlfelge/gdx-websockets/core/1.1.0/core-1.1.0.pom——https://oss.sonatype.org/content/repositories/snapshots/com/github/MrStahlfelge/gdx-websockets/core/1.1.0/core-1.1.0.pom——https://oss.sonatype.org/content/repositories/releases/com/github/MrStahlfelge/gdx-websockets/core/1.1.0/core-1.1.0.pom——https://jitpack.io/com/github/MrStahlfelge/gdx-websockets/core/1.1.0/core-1.1.0.pom要求:核心项目:
- 试题:
使用——stacktrace选项运行以获取堆栈跟踪。使用——info或——debug选项运行以获得更多的日志输出。运行——scan以获得完整的见解。
- 更多帮助请访问https://help.gradle.org
这到底是什么,我该如何修复它?
libgdx安装程序为所有com.github.MrStahlfelge使用1.1.0。Gdx-websockets依赖项似乎不存在。
替换为github页面上发布的1.9.10.3或更高版本https://github.com/MrStahlfelge/gdx-websockets