-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: include missing connector libs
- Loading branch information
1 parent
850e0ce
commit 42c257b
Showing
8 changed files
with
725 additions
and
0 deletions.
There are no files selected for viewing
108 changes: 108 additions & 0 deletions
108
buttplug4j.connectors.javax.websocket.client/build.gradle
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,108 @@ | ||
plugins { | ||
id 'java-library' | ||
id 'jacoco' | ||
id 'maven-publish' | ||
id 'checkstyle' | ||
id 'signing' | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
api project(':buttplug4j.connectors.javax.websocket.common') | ||
api 'org.eclipse.jetty.websocket:websocket-javax-client:10.0.15' | ||
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.0' | ||
} | ||
|
||
java { | ||
toolchain { | ||
languageVersion = JavaLanguageVersion.of(11) | ||
} | ||
withJavadocJar() | ||
withSourcesJar() | ||
} | ||
checkstyle { | ||
configFile = file("${rootDir}/checkstyle.xml") | ||
showViolations = false | ||
ignoreFailures = true | ||
} | ||
test { | ||
finalizedBy jacocoTestReport | ||
finalizedBy check | ||
} | ||
jacocoTestReport { | ||
dependsOn test | ||
} | ||
tasks.named('test') { | ||
useJUnitPlatform() | ||
} | ||
|
||
jacocoTestReport { | ||
reports { | ||
xml.required = true | ||
csv.required = true | ||
} | ||
} | ||
|
||
publishing { | ||
repositories { | ||
maven { | ||
name = "GitHubPackages" | ||
url = uri("https://maven.pkg.github.com/${System.env.GITHUB_REPOSITORY}") | ||
credentials { | ||
username = project.findProperty("gpr.user") ?: System.getenv("GITHUB_ACTOR") | ||
password = project.findProperty("gpr.key") ?: System.getenv("GITHUB_TOKEN") | ||
} | ||
} | ||
maven { | ||
name = "ossrh" | ||
url = version.contains("-SNAPSHOT") ? | ||
uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") : | ||
uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") | ||
|
||
credentials { | ||
username = project.findProperty("maven.user") ?:System.getenv("MAVEN_USER") | ||
password = project.findProperty("maven.pass") ?:System.getenv("MAVEN_PASS") | ||
} | ||
} | ||
} | ||
publications { | ||
mavenJava(MavenPublication) { | ||
from(components.java) | ||
pom { | ||
name = 'Buttplug for Java' | ||
description = 'A pure Java Buttplug Client implementation' | ||
url = 'https://github.com/blackspherefollower/buttplug4j' | ||
inceptionYear = '2017' | ||
|
||
licenses { | ||
license { | ||
name = 'BSDv3 License' | ||
url = 'https://github.com/blackspherefollower/buttplug4j/' | ||
} | ||
} | ||
developers { | ||
developer { | ||
id = 'blackspherefollower' | ||
name = 'BlackSphereFollower' | ||
email = 'blackspherefollower@iostindex.com' | ||
} | ||
} | ||
scm { | ||
connection='scm:git:git:github.com/blackspherefollower/buttplug4j.git' | ||
developerConnection='scm:git:https://github.com/blackspherefollower/buttplug4j.git' | ||
url='https://github.com/blackspherefollower/buttplug4j' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
signing { | ||
def gpgKey = project.findProperty("gpg.key") ?: System.getenv("OSSRH_GPG") ?: "" | ||
def gpgPass = project.findProperty("gpg.pass") ?: System.getenv("OSSRH_GPG_PASS") ?: "" | ||
useInMemoryPgpKeys(gpgKey.replaceAll("\\\\n", "\n"), gpgPass) | ||
sign publishing.publications.mavenJava | ||
} |
57 changes: 57 additions & 0 deletions
57
...github/blackspherefollower/buttplug4j/connectors/javax/client/ButtplugClientWSClient.java
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,57 @@ | ||
package io.github.blackspherefollower.buttplug4j.connectors.javax.client; | ||
|
||
import io.github.blackspherefollower.buttplug4j.client.ButtplugClient; | ||
import io.github.blackspherefollower.buttplug4j.connectors.javax.common.ButtplugClientWSEndpoint; | ||
import org.eclipse.jetty.util.component.LifeCycle; | ||
|
||
import javax.websocket.ClientEndpoint; | ||
import javax.websocket.ContainerProvider; | ||
import javax.websocket.DeploymentException; | ||
import javax.websocket.WebSocketContainer; | ||
import java.io.IOException; | ||
import java.net.URI; | ||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.ExecutionException; | ||
|
||
@ClientEndpoint | ||
public final class ButtplugClientWSClient extends ButtplugClientWSEndpoint { | ||
|
||
private WebSocketContainer client; | ||
|
||
public ButtplugClientWSClient(final String clientName) { | ||
super(clientName); | ||
} | ||
|
||
public void connect(final URI url) throws IllegalStateException, DeploymentException, IOException, | ||
ExecutionException, InterruptedException { | ||
|
||
if (client != null && getSession() != null && getSession().isOpen()) { | ||
throw new IllegalStateException("WS is already open"); | ||
} | ||
setConnectionState(ButtplugClient.ConnectionState.CONNECTING); | ||
|
||
CompletableFuture<Boolean> promise = new CompletableFuture<>(); | ||
setOnConnected(client -> promise.complete(true)); | ||
|
||
client = ContainerProvider.getWebSocketContainer(); | ||
client.connectToServer(this, url); | ||
promise.get(); | ||
} | ||
|
||
protected void cleanup() { | ||
|
||
if (getSession() != null) { | ||
try { | ||
getSession().close(); | ||
} catch (IOException e) { | ||
// noop - something when wrong closing the socket, but we're | ||
// about to dispose of it anyway. | ||
} | ||
} | ||
|
||
LifeCycle.stop(client); | ||
client = null; | ||
} | ||
|
||
|
||
} |
53 changes: 53 additions & 0 deletions
53
...thub/blackspherefollower/buttplug4j/connectors/javax/client/ButtplugWSClientMockTest.java
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,53 @@ | ||
package io.github.blackspherefollower.buttplug4j.connectors.javax.client; | ||
|
||
import io.github.blackspherefollower.buttplug4j.client.ButtplugClientDevice; | ||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.net.URI; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class ButtplugWSClientMockTest { | ||
|
||
@Disabled | ||
@Test | ||
public void TestConnect() throws Exception { | ||
ButtplugClientWSClient client = new ButtplugClientWSClient("Java Test"); | ||
client.connect(new URI("ws://localhost:12345/buttplug")); | ||
client.startScanning(); | ||
|
||
Thread.sleep(5000); | ||
client.requestDeviceList(); | ||
for (ButtplugClientDevice dev : client.getDevices()) { | ||
if (dev.getScalarVibrateCount() > 0) { | ||
dev.sendScalarVibrateCmd(0.5).get(); | ||
} | ||
} | ||
|
||
Thread.sleep(1000); | ||
assertTrue(client.stopAllDevices()); | ||
|
||
Thread.sleep(60000); | ||
for (ButtplugClientDevice dev : client.getDevices()) { | ||
if (dev.getScalarVibrateCount() > 0) { | ||
dev.sendScalarVibrateCmd(0.5).get(); | ||
} | ||
} | ||
|
||
Thread.sleep(1000); | ||
assertTrue(client.stopAllDevices()); | ||
|
||
Thread.sleep(60000); | ||
for (ButtplugClientDevice dev : client.getDevices()) { | ||
if (dev.getScalarVibrateCount() > 0) { | ||
dev.sendScalarVibrateCmd(0.5).get(); | ||
} | ||
} | ||
|
||
Thread.sleep(1000); | ||
assertTrue(client.stopAllDevices()); | ||
|
||
client.disconnect(); | ||
} | ||
} |
107 changes: 107 additions & 0 deletions
107
buttplug4j.connectors.javax.websocket.common/build.gradle
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,107 @@ | ||
plugins { | ||
id 'java-library' | ||
id 'jacoco' | ||
id 'maven-publish' | ||
id 'checkstyle' | ||
id 'signing' | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
api project(':buttplug4j') | ||
api 'javax.websocket:javax.websocket-api:1.1' | ||
} | ||
|
||
java { | ||
toolchain { | ||
languageVersion = JavaLanguageVersion.of(11) | ||
} | ||
withJavadocJar() | ||
withSourcesJar() | ||
} | ||
checkstyle { | ||
configFile = file("${rootDir}/checkstyle.xml") | ||
showViolations = false | ||
ignoreFailures = true | ||
} | ||
test { | ||
finalizedBy jacocoTestReport | ||
finalizedBy check | ||
} | ||
jacocoTestReport { | ||
dependsOn test | ||
} | ||
tasks.named('test') { | ||
useJUnitPlatform() | ||
} | ||
|
||
jacocoTestReport { | ||
reports { | ||
xml.required = true | ||
csv.required = true | ||
} | ||
} | ||
|
||
publishing { | ||
repositories { | ||
maven { | ||
name = "GitHubPackages" | ||
url = uri("https://maven.pkg.github.com/${System.env.GITHUB_REPOSITORY}") | ||
credentials { | ||
username = project.findProperty("gpr.user") ?: System.getenv("GITHUB_ACTOR") | ||
password = project.findProperty("gpr.key") ?: System.getenv("GITHUB_TOKEN") | ||
} | ||
} | ||
maven { | ||
name = "ossrh" | ||
url = version.contains("-SNAPSHOT") ? | ||
uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") : | ||
uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") | ||
|
||
credentials { | ||
username = project.findProperty("maven.user") ?:System.getenv("MAVEN_USER") | ||
password = project.findProperty("maven.pass") ?:System.getenv("MAVEN_PASS") | ||
} | ||
} | ||
} | ||
publications { | ||
mavenJava(MavenPublication) { | ||
from(components.java) | ||
pom { | ||
name = 'Buttplug for Java' | ||
description = 'A pure Java Buttplug Client implementation' | ||
url = 'https://github.com/blackspherefollower/buttplug4j' | ||
inceptionYear = '2017' | ||
|
||
licenses { | ||
license { | ||
name = 'BSDv3 License' | ||
url = 'https://github.com/blackspherefollower/buttplug4j/' | ||
} | ||
} | ||
developers { | ||
developer { | ||
id = 'blackspherefollower' | ||
name = 'BlackSphereFollower' | ||
email = 'blackspherefollower@iostindex.com' | ||
} | ||
} | ||
scm { | ||
connection='scm:git:git:github.com/blackspherefollower/buttplug4j.git' | ||
developerConnection='scm:git:https://github.com/blackspherefollower/buttplug4j.git' | ||
url='https://github.com/blackspherefollower/buttplug4j' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
signing { | ||
def gpgKey = project.findProperty("gpg.key") ?: System.getenv("OSSRH_GPG") ?: "" | ||
def gpgPass = project.findProperty("gpg.pass") ?: System.getenv("OSSRH_GPG_PASS") ?: "" | ||
useInMemoryPgpKeys(gpgKey.replaceAll("\\\\n", "\n"), gpgPass) | ||
sign publishing.publications.mavenJava | ||
} |
Oops, something went wrong.