Skip to content

Commit

Permalink
chore: Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
blackspherefollower committed Aug 8, 2023
1 parent 99d559d commit 4ea6d50
Show file tree
Hide file tree
Showing 22 changed files with 149 additions and 206 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
github: blackspherefollower
github: blackspherefollower
patreon: blackspherefollower
ko_fi: blackspherefollower
54 changes: 27 additions & 27 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,38 +39,38 @@ jobs:
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh
# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
8 changes: 4 additions & 4 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

Only the latest release is considered supported.

| Version | Supported |
| ------- | ------------------ |
| 3.0.x ||
| 0.0.x ||
| Version | Supported |
|---------|-----------|
| 3.0.x | |
| 0.0.x | |

## Reporting a Vulnerability

Expand Down
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

subprojects { project ->
group = 'io.github.blackspherefollower'
version = "3.1." + ("${System.env.GITHUB_RUN_NUMBER ?: 1}") + ("${System.env.GITHUB_REF_TYPE}" == "tag" ? "" : "-SNAPSHOT")
Expand Down
10 changes: 5 additions & 5 deletions buttplug4j.connectors.javax.websocket.client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ publishing {
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")
username = project.findProperty("maven.user") ?: System.getenv("MAVEN_USER")
password = project.findProperty("maven.pass") ?: System.getenv("MAVEN_PASS")
}
}
}
Expand All @@ -91,9 +91,9 @@ publishing {
}
}
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'
connection = 'scm:git:git:github.com/blackspherefollower/buttplug4j.git'
developerConnection = 'scm:git:https://github.com/blackspherefollower/buttplug4j.git'
url = 'https://github.com/blackspherefollower/buttplug4j'
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions buttplug4j.connectors.javax.websocket.common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ publishing {
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")
username = project.findProperty("maven.user") ?: System.getenv("MAVEN_USER")
password = project.findProperty("maven.pass") ?: System.getenv("MAVEN_PASS")
}
}
}
Expand All @@ -90,9 +90,9 @@ publishing {
}
}
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'
connection = 'scm:git:git:github.com/blackspherefollower/buttplug4j.git'
developerConnection = 'scm:git:https://github.com/blackspherefollower/buttplug4j.git'
url = 'https://github.com/blackspherefollower/buttplug4j'
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@
import io.github.blackspherefollower.buttplug4j.protocol.ButtplugProtocolException;
import io.github.blackspherefollower.buttplug4j.protocol.messages.Error;

import javax.websocket.ClientEndpoint;
import javax.websocket.CloseReason;
import javax.websocket.OnClose;
import javax.websocket.OnError;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.*;
import javax.websocket.server.ServerEndpoint;
import java.io.IOException;
import java.nio.ByteBuffer;
Expand All @@ -24,10 +18,10 @@
@ClientEndpoint
@ServerEndpoint("/")
public abstract class ButtplugClientWSEndpoint extends ButtplugClient {
private static final int TENSEC = 10000;
private Session session;
private Timer wsPingTimer;


public ButtplugClientWSEndpoint(final String aClientName) {
super(aClientName);
}
Expand All @@ -36,8 +30,6 @@ public final Session getSession() {
return session;
}

private static final int TENSEC = 10000;

@OnMessage
public final void onMessage(final Session sess, final String message) {
try {
Expand Down
10 changes: 5 additions & 5 deletions buttplug4j.connectors.javax.websocket.server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ publishing {
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")
username = project.findProperty("maven.user") ?: System.getenv("MAVEN_USER")
password = project.findProperty("maven.pass") ?: System.getenv("MAVEN_PASS")
}
}
}
Expand All @@ -91,9 +91,9 @@ publishing {
}
}
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'
connection = 'scm:git:git:github.com/blackspherefollower/buttplug4j.git'
developerConnection = 'scm:git:https://github.com/blackspherefollower/buttplug4j.git'
url = 'https://github.com/blackspherefollower/buttplug4j'
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,60 +55,60 @@ public ButtplugClientWSServerExample(int port) throws Exception {
wsContainer.addEndpoint(ServerEndpointConfig.Builder.create(ButtplugClientWSEndpoint.class, "/{user}").configurator(new ServerEndpointConfig.Configurator() {
@Override
public <T> T getEndpointInstance(Class<T> endpointClass) {
if(endpointClass == ButtplugClientWSEndpoint.class) {
if (endpointClass == ButtplugClientWSEndpoint.class) {
ButtplugClientWSServer client = new ButtplugClientWSServer("Java WS Server Buttplug Client");
client.setOnConnected(new IConnectedEvent() {
@Override
public void onConnected(ButtplugClient client) {
new Thread(() -> {
try {
if( client instanceof ButtplugClientWSServer ) {
if (client instanceof ButtplugClientWSServer) {
Session s = ((ButtplugClientWSServer) client).getSession();
s.getPathParameters().forEach((k,v) -> {
s.getPathParameters().forEach((k, v) -> {
System.out.printf("param: %s -> %s\n", k, v);
});
}

client.startScanning();

Thread.sleep(5000);
client.requestDeviceList();
for (
ButtplugClientDevice dev : client.getDevices()) {
if (dev.getScalarVibrateCount() > 0) {
dev.sendScalarVibrateCmd(0.5).get();
Thread.sleep(5000);
client.requestDeviceList();
for (
ButtplugClientDevice dev : client.getDevices()) {
if (dev.getScalarVibrateCount() > 0) {
dev.sendScalarVibrateCmd(0.5).get();
}
}
}

Thread.sleep(1000);
Thread.sleep(1000);

assertTrue(client.stopAllDevices());
assertTrue(client.stopAllDevices());

Thread.sleep(60000);
for (
ButtplugClientDevice dev : client.getDevices()) {
if (dev.getScalarVibrateCount() > 0) {
dev.sendScalarVibrateCmd(0.5).get();
Thread.sleep(60000);
for (
ButtplugClientDevice dev : client.getDevices()) {
if (dev.getScalarVibrateCount() > 0) {
dev.sendScalarVibrateCmd(0.5).get();
}
}
}

Thread.sleep(1000);
Thread.sleep(1000);

assertTrue(client.stopAllDevices());
assertTrue(client.stopAllDevices());

Thread.sleep(60000);
for (
ButtplugClientDevice dev : client.getDevices()) {
if (dev.getScalarVibrateCount() > 0) {
dev.sendScalarVibrateCmd(0.5).get();
Thread.sleep(60000);
for (
ButtplugClientDevice dev : client.getDevices()) {
if (dev.getScalarVibrateCount() > 0) {
dev.sendScalarVibrateCmd(0.5).get();
}
}
}

Thread.sleep(1000);
Thread.sleep(1000);

assertTrue(client.stopAllDevices());
assertTrue(client.stopAllDevices());

client.disconnect();
client.disconnect();
} catch (ExecutionException e) {
throw new RuntimeException(e);
} catch (InterruptedException e) {
Expand All @@ -121,7 +121,7 @@ public void onConnected(ButtplugClient client) {
}).start();
}
});
return (T)client;
return (T) client;
}
return null;
}
Expand All @@ -130,18 +130,15 @@ public void onConnected(ButtplugClient client) {
server.start();
}

public URI getURI()
{
public URI getURI() {
return server.getURI();
}

public void stop() throws Exception
{
public void stop() throws Exception {
server.stop();
}

public void join() throws InterruptedException
{
public void join() throws InterruptedException {
server.join();
}
}
Expand Down
10 changes: 5 additions & 5 deletions buttplug4j.connectors.jetty.websocket.client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ publishing {
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")
username = project.findProperty("maven.user") ?: System.getenv("MAVEN_USER")
password = project.findProperty("maven.pass") ?: System.getenv("MAVEN_PASS")
}
}
}
Expand All @@ -92,9 +92,9 @@ publishing {
}
}
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'
connection = 'scm:git:git:github.com/blackspherefollower/buttplug4j.git'
developerConnection = 'scm:git:https://github.com/blackspherefollower/buttplug4j.git'
url = 'https://github.com/blackspherefollower/buttplug4j'
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import io.github.blackspherefollower.buttplug4j.protocol.ButtplugProtocolException;
import io.github.blackspherefollower.buttplug4j.protocol.messages.Error;
import org.eclipse.jetty.util.component.LifeCycle;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.annotations.*;
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.eclipse.jetty.websocket.api.Session;

import java.io.IOException;
import java.net.URI;
Expand All @@ -18,14 +18,14 @@
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

@WebSocket(maxTextMessageSize = 64 * 1024)
public final class ButtplugClientWSClient extends ButtplugClient {

private static final int TENSEC = 10000;
private WebSocketClient client;

private Session session;
private Timer wsPingTimer;

public ButtplugClientWSClient(final String clientName) {
super(clientName);
Expand Down Expand Up @@ -88,13 +88,8 @@ public void run() {
new Thread(() -> doHandshake()).start();
}

private Timer wsPingTimer;


private static final int TENSEC = 10000;

@OnWebSocketMessage
public final void onMessage(final Session sess, final String message) {
public void onMessage(final Session sess, final String message) {
try {
List<ButtplugMessage> msgs = getParser().parseJson(message);
onMessage(msgs);
Expand Down
Loading

0 comments on commit 4ea6d50

Please sign in to comment.