Skip to content

Commit cbe785f

Browse files
committed
feat: add connection state recovery and flexible auth
- Implement Socket.IO v4 connection state recovery * Track PID and offset for session restoration * Add isRecovered() and getLastOffset() methods * Replay missed events after reconnect - Change auth from Map to JSONObject for flexibility - Upgrade test server from Socket.IO v3.0.4 to v4.8.1 * Fix tests for v4 offset parameter * Fix namespace emission bugs BREAKING CHANGE: auth is now JSONObject instead of Map<String,String>
1 parent eb438de commit cbe785f

File tree

12 files changed

+591
-413
lines changed

12 files changed

+591
-413
lines changed

pom.xml

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>io.socket</groupId>
44
<artifactId>socket.io-client</artifactId>
5-
<version>2.1.3-SNAPSHOT</version>
5+
<version>2.1.52-SNAPSHOT</version>
66
<packaging>jar</packaging>
77
<name>socket.io-client</name>
88
<description>Socket.IO Client Library for Java</description>
@@ -102,20 +102,6 @@
102102

103103
<build>
104104
<plugins>
105-
<plugin>
106-
<groupId>org.apache.maven.plugins</groupId>
107-
<artifactId>maven-compiler-plugin</artifactId>
108-
<version>3.5.1</version>
109-
<configuration>
110-
<source>1.7</source>
111-
<target>1.7</target>
112-
<compilerArgs>
113-
<arg>-Xlint:unchecked</arg>
114-
</compilerArgs>
115-
<showWarnings>true</showWarnings>
116-
<showDeprecation>true</showDeprecation>
117-
</configuration>
118-
</plugin>
119105
<plugin>
120106
<groupId>org.apache.maven.plugins</groupId>
121107
<artifactId>maven-surefire-plugin</artifactId>
@@ -207,7 +193,7 @@
207193
<workingDirectory>./src/test/resources</workingDirectory>
208194
<executable>npm</executable>
209195
<arguments>
210-
<argument>install</argument>
196+
<argument>install</argument>
211197
</arguments>
212198
</configuration>
213199
</execution>
@@ -223,6 +209,44 @@
223209
<artifactId>maven-site-plugin</artifactId>
224210
<version>3.9.1</version>
225211
</plugin>
212+
<plugin>
213+
<groupId>org.apache.maven.plugins</groupId>
214+
<artifactId>maven-compiler-plugin</artifactId>
215+
<version>3.5.1</version>
216+
<executions>
217+
<execution>
218+
<id>default-compile</id>
219+
<phase>none</phase>
220+
</execution>
221+
<execution>
222+
<id>default-testCompile</id>
223+
<phase>none</phase>
224+
</execution>
225+
<execution>
226+
<id>compile</id>
227+
<phase>compile</phase>
228+
<goals>
229+
<goal>compile</goal>
230+
</goals>
231+
</execution>
232+
<execution>
233+
<id>testCompile</id>
234+
<phase>test-compile</phase>
235+
<goals>
236+
<goal>testCompile</goal>
237+
</goals>
238+
</execution>
239+
</executions>
240+
<configuration>
241+
<source>1.8</source>
242+
<target>1.8</target>
243+
<compilerArgs>
244+
<arg>-Xlint:unchecked</arg>
245+
</compilerArgs>
246+
<showWarnings>true</showWarnings>
247+
<showDeprecation>true</showDeprecation>
248+
</configuration>
249+
</plugin>
226250
</plugins>
227251
</build>
228252
</project>

src/main/java/io/socket/client/Manager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import io.socket.thread.EventThread;
1010
import okhttp3.Call;
1111
import okhttp3.WebSocket;
12+
import org.json.JSONObject;
1213

1314
import java.net.URI;
1415
import java.util.*;
@@ -562,7 +563,7 @@ public static class Options extends io.socket.engineio.client.Socket.Options {
562563
public double randomizationFactor;
563564
public Parser.Encoder encoder;
564565
public Parser.Decoder decoder;
565-
public Map<String, String> auth;
566+
public JSONObject auth;
566567

567568
/**
568569
* Connection timeout (ms). Set -1 to disable.

0 commit comments

Comments
 (0)