Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,19 @@

<!-- Checks for imports -->
<!-- See http://checkstyle.sf.net/config_import.html -->
<!--module name="AvoidStarImport"/-->
<module name="AvoidStarImport"/>
<module name="IllegalImport"/>
<!-- defaults to sun.* packages -->
<module name="RedundantImport"/>
<module name="UnusedImports"/>

<module name="ImportOrder">
<property name="groups" value="java,javax,org,com"/>
<property name="ordered" value="true"/>
<property name="separated" value="true"/>
<property name="caseSensitive" value="true"/>
<!-- 支持静态导入排序 -->
<property name="option" value="bottom"/>
<property name="sortStaticImportsAlphabetically" value="true"/>
</module>

<!-- Checks for Size Violations. -->
<!-- See http://checkstyle.sf.net/config_sizes.html -->
Expand Down
2 changes: 1 addition & 1 deletion header.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2012-2023 Nikita Koksharov
Copyright (c) 2012-2025 Nikita Koksharov

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
102 changes: 93 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<skipTests>true</skipTests>
<skipTests>false</skipTests>
<netty.version>4.1.119.Final</netty.version>
<jmockit.version>1.49</jmockit.version>
<byte-buddy.version>1.14.9</byte-buddy.version>
</properties>

<profiles>
Expand Down Expand Up @@ -174,13 +176,30 @@
<dependency>
<groupId>org.jmockit</groupId>
<artifactId>jmockit</artifactId>
<version>1.49</version>
<version>${jmockit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-agent</artifactId>
<version>${byte-buddy.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.10.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.10.1</version>
<scope>test</scope>
</dependency>

Expand Down Expand Up @@ -234,8 +253,66 @@
<version>3.12.12</version>
<scope>provided</scope>
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>4.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.24.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.7.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.4.11</version>
<scope>test</scope>
</dependency>

<!-- Socket.IO client for testing -->
<dependency>
<groupId>io.socket</groupId>
<artifactId>socket.io-client</artifactId>
<version>2.1.0</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.github.javafaker/javafaker -->
<dependency>
<groupId>com.github.javafaker</groupId>
<artifactId>javafaker</artifactId>
<version>1.0.2</version>
<scope>test</scope>
</dependency>
</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-bom</artifactId>
<version>1.21.3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>


<build>
<plugins>
Expand Down Expand Up @@ -320,12 +397,11 @@
<configuration>
<linkXref>true</linkXref>
<minimumTokens>100</minimumTokens>
<targetJdk>1.6</targetJdk>
<targetJdk>1.8</targetJdk>
<verbose>true</verbose>
</configuration>
</plugin>

<!--
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
Expand All @@ -345,7 +421,6 @@
<excludes>**/module-info.java</excludes>
</configuration>
</plugin>
-->

<plugin>
<!-- this trick double-compiles everything so we can have a module-info.class
Expand Down Expand Up @@ -411,8 +486,17 @@
<version>3.2.5</version>
<configuration>
<argLine>
-javaagent:"${settings.localRepository}"/org/jmockit/jmockit/1.46/jmockit-1.46.jar
-javaagent:"${settings.localRepository}"/org/jmockit/jmockit/${jmockit.version}/jmockit-${jmockit.version}.jar
-javaagent:"${settings.localRepository}"/net/bytebuddy/byte-buddy-agent/${byte-buddy.version}/byte-buddy-agent-${byte-buddy.version}.jar
--add-opens netty.socketio/com.corundumstudio.socketio.store.pubsub=ALL-UNNAMED
--add-opens netty.socketio/com.corundumstudio.socketio.store=ALL-UNNAMED
--add-opens netty.socketio/com.corundumstudio.socketio.store.pubsub=redisson
--add-opens netty.socketio/com.corundumstudio.socketio.store=redisson
</argLine>
<includes>
<include>**/*Test.java</include>
<include>**/*Tests.java</include>
</includes>
</configuration>
</plugin>

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/corundumstudio/socketio/AckCallback.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2012-2023 Nikita Koksharov
* Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/corundumstudio/socketio/AckMode.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2012-2023 Nikita Koksharov
* Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/corundumstudio/socketio/AckRequest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2012-2023 Nikita Koksharov
* Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -64,7 +64,7 @@ public boolean isAckRequested() {
*
* @param objs - ack data objects
*/
public void sendAckData(Object ... objs) {
public void sendAckData(Object... objs) {
List<Object> args = Arrays.asList(objs);
sendAckData(args);
}
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/corundumstudio/socketio/AuthTokenListener.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.corundumstudio.socketio;

/**
Expand Down
17 changes: 16 additions & 1 deletion src/main/java/com/corundumstudio/socketio/AuthTokenResult.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.corundumstudio.socketio;

/**
Expand All @@ -18,7 +33,7 @@

public class AuthTokenResult {

public final static AuthTokenResult AuthTokenResultSuccess = new AuthTokenResult(true, null);
public static final AuthTokenResult AUTH_TOKEN_RESULT_SUCCESS = new AuthTokenResult(true, null);
private final boolean success;
private final Object errorData;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2012-2023 Nikita Koksharov
* Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,7 +19,7 @@ public interface AuthorizationListener {

/**
* Checks whether a client with handshake data is authorized on connection
* Optionally returns storeParams that will be added to {@link SocketIOClient} store
* Optionally returns storeParams that will be added to {@link SocketIOClient} store
*
* @param data handshake data
* @return - {@link AuthorizationResult}
Expand Down
57 changes: 30 additions & 27 deletions src/main/java/com/corundumstudio/socketio/AuthorizationResult.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2012-2023 Nikita Koksharov
* Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,34 +20,37 @@

public class AuthorizationResult {

public static final AuthorizationResult SUCCESSFUL_AUTHORIZATION = new AuthorizationResult(true);
public static final AuthorizationResult FAILED_AUTHORIZATION = new AuthorizationResult(false);
private final boolean isAuthorized;
private final Map<String, Object> storeParams;
public static final AuthorizationResult SUCCESSFUL_AUTHORIZATION = new AuthorizationResult(true);
public static final AuthorizationResult FAILED_AUTHORIZATION = new AuthorizationResult(false);
private final boolean isAuthorized;
private final Map<String, Object> storeParams;

public AuthorizationResult(boolean isAuthorized) {
this.isAuthorized = isAuthorized;
this.storeParams = Collections.emptyMap();
}
public AuthorizationResult(boolean isAuthorized) {
this.isAuthorized = isAuthorized;
this.storeParams = Collections.emptyMap();
}

public AuthorizationResult(boolean isAuthorized, Map<String, Object> storeParams) {
this.isAuthorized = isAuthorized;
this.storeParams = isAuthorized && storeParams != null ?
Collections.unmodifiableMap(storeParams) : Collections.emptyMap();
}
public AuthorizationResult(boolean isAuthorized, Map<String, Object> storeParams) {
this.isAuthorized = isAuthorized;
if (isAuthorized && storeParams != null) {
this.storeParams = Collections.unmodifiableMap(storeParams);
} else {
this.storeParams = Collections.emptyMap();
}
}

/**
* @return <b>true</b> if a client is authorized, otherwise - <b>false</b>
* */
public boolean isAuthorized() {
return isAuthorized;
}
/**
* @return <b>true</b> if a client is authorized, otherwise - <b>false</b>
* */
public boolean isAuthorized() {
return isAuthorized;
}

/**
* @return key-value pairs (unmodifiable) that will be added to {@link SocketIOClient } store.
* If a client is not authorized, storeParams will always be ignored (empty map)
* */
public Map<String, Object> getStoreParams() {
return storeParams;
}
/**
* @return key-value pairs (unmodifiable) that will be added to {@link SocketIOClient } store.
* If a client is not authorized, storeParams will always be ignored (empty map)
* */
public Map<String, Object> getStoreParams() {
return storeParams;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2012-2023 Nikita Koksharov
* Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2012-2023 Nikita Koksharov
* Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,11 +15,11 @@
*/
package com.corundumstudio.socketio;

import com.corundumstudio.socketio.protocol.Packet;

import java.util.Collection;
import java.util.function.Predicate;

import com.corundumstudio.socketio.protocol.Packet;

/**
* broadcast interface
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2012-2023 Nikita Koksharov
* Copyright (c) 2012-2025 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -44,6 +44,6 @@ public interface ClientOperations {
* @param name - event name
* @param data - event data
*/
void sendEvent(String name, Object ... data);
void sendEvent(String name, Object... data);

}
Loading