Skip to content

Commit 29f179e

Browse files
committed
Initial commit
0 parents  commit 29f179e

File tree

18 files changed

+1281
-0
lines changed

18 files changed

+1281
-0
lines changed

.gitignore

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
*.class
2+
3+
# Package Files #
4+
*.jar
5+
*.war
6+
*.ear
7+
8+
# Intellij project files
9+
*.iml
10+
*.ipr
11+
*.iws
12+
.idea/
13+
14+
.DS_Store
15+
target/
16+
node_modules/

.travis.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
language: java
2+
jdk:
3+
- openjdk7
4+
- oraclejdk7

LICENSE

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
The MIT License (MIT)
2+
Copyright (c) 2013 Naoyuki Kanezawa
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5+
6+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7+
8+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9+
10+
11+
(The MIT License)
12+
13+
Copyright (c) 2011 Guillermo Rauch <[email protected]>
14+
15+
Permission is hereby granted, free of charge, to any person obtaining
16+
a copy of this software and associated documentation files (the
17+
'Software'), to deal in the Software without restriction, including
18+
without limitation the rights to use, copy, modify, merge, publish,
19+
distribute, sublicense, and/or sell copies of the Software, and to
20+
permit persons to whom the Software is furnished to do so, subject to
21+
the following conditions:
22+
23+
The above copyright notice and this permission notice shall be
24+
included in all copies or substantial portions of the Software.
25+
26+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
27+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
29+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
30+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
31+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
32+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Socket.IO-client.java
2+
3+
This is the Socket.IO 1.0 Client Library for Java.
4+
5+
## License
6+
7+
MIT
8+

pom.xml

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
4+
<groupId>com.github.nkzawa</groupId>
5+
<artifactId>socket.io-client</artifactId>
6+
<version>0.0.1-SNAPSHOT</version>
7+
8+
<repositories>
9+
<repository>
10+
<id>sonatype-oss-public</id>
11+
<url>https://oss.sonatype.org/content/groups/public/</url>
12+
<releases>
13+
<enabled>true</enabled>
14+
</releases>
15+
<snapshots>
16+
<enabled>true</enabled>
17+
</snapshots>
18+
</repository>
19+
</repositories>
20+
21+
<dependencies>
22+
<dependency>
23+
<groupId>com.github.nkzawa</groupId>
24+
<artifactId>engine.io-client</artifactId>
25+
<version>0.0.1-SNAPSHOT</version>
26+
</dependency>
27+
<dependency>
28+
<groupId>junit</groupId>
29+
<artifactId>junit</artifactId>
30+
<version>4.11</version>
31+
<scope>test</scope>
32+
</dependency>
33+
</dependencies>
34+
35+
<build>
36+
<plugins>
37+
<plugin>
38+
<groupId>org.apache.maven.plugins</groupId>
39+
<artifactId>maven-compiler-plugin</artifactId>
40+
<version>3.0</version>
41+
<configuration>
42+
<source>1.6</source>
43+
<target>1.6</target>
44+
</configuration>
45+
</plugin>
46+
<plugin>
47+
<groupId>org.codehaus.mojo</groupId>
48+
<artifactId>exec-maven-plugin</artifactId>
49+
<version>1.2.1</version>
50+
<executions>
51+
<execution>
52+
<id>npm-install</id>
53+
<phase>process-test-resources</phase>
54+
<goals>
55+
<goal>exec</goal>
56+
</goals>
57+
<configuration>
58+
<workingDirectory>./src/test/resources</workingDirectory>
59+
<executable>npm</executable>
60+
<arguments>
61+
<argument>install</argument>
62+
</arguments>
63+
</configuration>
64+
</execution>
65+
</executions>
66+
</plugin>
67+
</plugins>
68+
</build>
69+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.github.nkzawa.socketio.client;
2+
3+
import java.net.URI;
4+
5+
class Engine extends com.github.nkzawa.engineio.client.Socket {
6+
7+
Engine(URI uri, Options opts) {
8+
super(uri, opts);
9+
}
10+
11+
@Override
12+
public void onopen() {}
13+
14+
@Override
15+
public void onmessage(String s) {}
16+
17+
@Override
18+
public void onclose() {}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package com.github.nkzawa.socketio.client;
2+
3+
4+
import com.github.nkzawa.socketio.parser.Parser;
5+
6+
import java.net.MalformedURLException;
7+
import java.net.URI;
8+
import java.net.URISyntaxException;
9+
import java.net.URL;
10+
import java.util.HashMap;
11+
import java.util.Map;
12+
13+
public class IO {
14+
15+
private static final Map<String, Manager> managers = new HashMap<String, Manager>();
16+
17+
public static int protocol = Parser.protocol;
18+
19+
private IO() {}
20+
21+
public static Socket socket(String uri) throws URISyntaxException {
22+
return socket(uri, null);
23+
}
24+
25+
public static Socket socket(String uri, Options opts) throws URISyntaxException {
26+
return socket(new URI(uri), opts);
27+
}
28+
29+
public static Socket socket(URI uri) throws URISyntaxException {
30+
return socket(uri, null);
31+
}
32+
33+
public static Socket socket(URI uri, Options opts) throws URISyntaxException {
34+
if (opts == null) {
35+
opts = new Options();
36+
}
37+
38+
URL parsed;
39+
try {
40+
parsed = Url.parse(uri);
41+
} catch (MalformedURLException e) {
42+
throw new URISyntaxException(uri.toString(), e.getMessage());
43+
}
44+
URI href = parsed.toURI();
45+
Manager io;
46+
47+
if (opts.forceNew || !opts.multiplex) {
48+
io = new Manager(href, opts);
49+
} else {
50+
String id = Url.extractId(parsed);
51+
if (!managers.containsKey(id)) {
52+
managers.put(id, new Manager(href, opts));
53+
}
54+
io = managers.get(id);
55+
}
56+
57+
String path = uri.getPath();
58+
return io.socket(path != null && !path.isEmpty() ? path : "/");
59+
}
60+
61+
62+
public static class Options extends com.github.nkzawa.engineio.client.Socket.Options {
63+
64+
public boolean forceNew;
65+
public boolean multiplex = true;
66+
public boolean reconnection;
67+
public int reconnectionAttempts;
68+
public long reconnectionDelay;
69+
public long reconnectionDelayMax;
70+
public long timeout = -1;
71+
72+
}
73+
}

0 commit comments

Comments
 (0)