Skip to content

Commit 0107212

Browse files
committed
Merge with e5686c14600e2288fe57dc91c58d206510ec7939
2 parents 09e24ad + 540cdf1 commit 0107212

File tree

4 files changed

+36
-37
lines changed

4 files changed

+36
-37
lines changed

.classpath

+2-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@
44
<classpathentry kind="src" path="examples"/>
55
<classpathentry kind="src" path="tests"/>
66
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
7-
<classpathentry exported="true" kind="lib" path="lib/json-org.jar">
8-
<attributes>
9-
<attribute name="javadoc_location" value="http://www.json.org/javadoc/"/>
10-
</attributes>
11-
</classpathentry>
127
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
13-
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/weberknecht"/>
8+
<classpathentry kind="lib" path="/socket.io-java-client-new/lib/json-org.jar"/>
9+
<classpathentry kind="lib" path="libs/weberknecht-0.1.1.jar"/>
1410
<classpathentry kind="output" path="bin"/>
1511
</classpath>
File renamed without changes.

libs/weberknecht-0.1.1.jar

10.6 KB
Binary file not shown.

src/io/socket/IOConnection.java

+34-31
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import java.util.TimerTask;
2626
import java.util.concurrent.ConcurrentLinkedQueue;
2727
import java.util.logging.Logger;
28-
2928
import javax.net.ssl.HttpsURLConnection;
3029
import javax.net.ssl.SSLSocketFactory;
3130

@@ -39,7 +38,7 @@
3938
class IOConnection implements IOCallback {
4039
/** Debug logger */
4140
static final Logger logger = Logger.getLogger("io.socket");
42-
41+
4342
public static final String FRAME_DELIMITER = "\ufffd";
4443

4544
/** The Constant STATE_INIT. */
@@ -67,8 +66,9 @@ class IOConnection implements IOCallback {
6766
public static final String SOCKET_IO_1 = "/socket.io/1/";
6867

6968
/** The SSL socket factory for HTTPS connections */
70-
private static SSLSocketFactory sslSocketFactory = (SSLSocketFactory)SSLSocketFactory.getDefault();
71-
69+
private static SSLSocketFactory sslSocketFactory = (SSLSocketFactory) SSLSocketFactory
70+
.getDefault();
71+
7272
/** All available connections. */
7373
private static HashMap<String, List<IOConnection>> connections = new HashMap<String, List<IOConnection>>();
7474

@@ -201,17 +201,17 @@ public void run() {
201201
connectTransport();
202202
}
203203

204-
205204
};
206205

207206
/**
208207
* Set the socket factory used for SSL connections.
208+
*
209209
* @param socketFactory
210210
*/
211211
public static void setDefaultSSLSocketFactory(SSLSocketFactory socketFactory) {
212212
sslSocketFactory = socketFactory;
213213
}
214-
214+
215215
/**
216216
* Creates a new connection or returns the corresponding one.
217217
*
@@ -269,7 +269,7 @@ public void unregister(SocketIO socket) {
269269
sendPlain("0::" + socket.getNamespace());
270270
sockets.remove(socket.getNamespace());
271271
socket.getCallback().onDisconnect();
272-
272+
273273
if (sockets.size() == 0) {
274274
cleanup();
275275
}
@@ -287,18 +287,19 @@ private void handshake() {
287287
setState(STATE_HANDSHAKE);
288288
url = new URL(IOConnection.this.url.toString() + SOCKET_IO_1);
289289
connection = url.openConnection();
290-
if(connection instanceof HttpsURLConnection) {
291-
((HttpsURLConnection)connection).setSSLSocketFactory(sslSocketFactory);
290+
if (connection instanceof HttpsURLConnection) {
291+
((HttpsURLConnection) connection)
292+
.setSSLSocketFactory(sslSocketFactory);
292293
}
293294
connection.setConnectTimeout(connectTimeout);
294295
connection.setReadTimeout(connectTimeout);
295-
296+
296297
/* Setting the request headers */
297298
for (Entry<Object, Object> entry : headers.entrySet()) {
298299
connection.setRequestProperty((String) entry.getKey(),
299300
(String) entry.getValue());
300301
}
301-
302+
302303
InputStream stream = connection.getInputStream();
303304
Scanner in = new Scanner(stream);
304305
response = in.nextLine();
@@ -487,15 +488,15 @@ private void resetTimeout() {
487488
* @param message
488489
* the message
489490
* @return the iO callback
490-
* @throws SocketIOException
491+
* @throws SocketIOException
491492
*/
492493
private IOCallback findCallback(IOMessage message) throws SocketIOException {
493-
if("".equals(message.getEndpoint()))
494+
if ("".equals(message.getEndpoint()))
494495
return this;
495496
SocketIO socket = sockets.get(message.getEndpoint());
496497
if (socket == null) {
497-
throw new SocketIOException("Cannot find socket for '" + message.getEndpoint()
498-
+ "'");
498+
throw new SocketIOException("Cannot find socket for '"
499+
+ message.getEndpoint() + "'");
499500
}
500501
return socket.getCallback();
501502
}
@@ -564,28 +565,31 @@ public void transportError(Exception error) {
564565
}
565566

566567
/**
567-
* {@link IOTransport} should call this function if it does not support framing. If it does, transportMessage should be used
568+
* {@link IOTransport} should call this function if it does not support
569+
* framing. If it does, transportMessage should be used
568570
*
569571
* @param text
570572
* the text
571573
*/
572574
public void transportData(String text) {
573-
if(!text.startsWith(FRAME_DELIMITER)) {
575+
if (!text.startsWith(FRAME_DELIMITER)) {
574576
transportMessage(text);
575577
return;
576578
}
577-
578-
Iterator<String> fragments = Arrays.asList(text.split(FRAME_DELIMITER)).listIterator(1);
579+
580+
Iterator<String> fragments = Arrays.asList(text.split(FRAME_DELIMITER))
581+
.listIterator(1);
579582
while (fragments.hasNext()) {
580583
int length = Integer.parseInt(fragments.next());
581584
String string = (String) fragments.next();
582-
// Potential BUG: it is not defined if length is in bytes or characters. Assuming characters.
583-
584-
if(length != string.length()) {
585+
// Potential BUG: it is not defined if length is in bytes or
586+
// characters. Assuming characters.
587+
588+
if (length != string.length()) {
585589
error(new SocketIOException("Garbage from server: " + text));
586590
return;
587591
}
588-
592+
589593
transportMessage(string);
590594
}
591595
}
@@ -678,8 +682,7 @@ public void transportMessage(String text) {
678682
if (args.isNull(i) == false)
679683
argsArray[i] = args.get(i);
680684
}
681-
}
682-
else
685+
} else
683686
argsArray = new Object[0];
684687
String eventName = event.getString("name");
685688
try {
@@ -869,38 +872,38 @@ public IOTransport getTransport() {
869872
@Override
870873
public void onDisconnect() {
871874
SocketIO socket = sockets.get("");
872-
if(socket != null)
875+
if (socket != null)
873876
socket.getCallback().onConnect();
874877
}
875878

876879
@Override
877880
public void onConnect() {
878881
SocketIO socket = sockets.get("");
879-
if(socket != null)
882+
if (socket != null)
880883
socket.getCallback().onConnect();
881884
}
882885

883886
@Override
884887
public void onMessage(String data, IOAcknowledge ack) {
885-
for(SocketIO socket : sockets.values())
888+
for (SocketIO socket : sockets.values())
886889
socket.getCallback().onMessage(data, ack);
887890
}
888891

889892
@Override
890893
public void onMessage(JSONObject json, IOAcknowledge ack) {
891-
for(SocketIO socket : sockets.values())
894+
for (SocketIO socket : sockets.values())
892895
socket.getCallback().onMessage(json, ack);
893896
}
894897

895898
@Override
896899
public void on(String event, IOAcknowledge ack, Object... args) {
897-
for(SocketIO socket : sockets.values())
900+
for (SocketIO socket : sockets.values())
898901
socket.getCallback().on(event, ack, args);
899902
}
900903

901904
@Override
902905
public void onError(SocketIOException socketIOException) {
903-
for(SocketIO socket : sockets.values())
906+
for (SocketIO socket : sockets.values())
904907
socket.getCallback().onError(socketIOException);
905908
}
906909
}

0 commit comments

Comments
 (0)