Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed XHRtransport to more cleanly deal with the case where the clien…
…t makes a second get attempt while one is already in progress. Added ConnectionState to SocketIOConnection. Fixed GWT impl so that host and port can be specified. Modified GWT impl so that a failed connect can be distinguished from a regular disconnect.
- Loading branch information
Showing
6 changed files
with
174 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,52 @@ | ||
package com.glines.socketio.client; | ||
|
||
public interface SocketIOConnection { | ||
public enum ConnectionState { | ||
CONNECTING, | ||
OPEN, | ||
CLOSING, | ||
CLOSED; | ||
} | ||
|
||
interface SocketIOConnectionListener { | ||
public abstract void onConnect(); | ||
public abstract void onDisconnect(); | ||
|
||
/** | ||
* Called when the connection closes or if the initial connection attempt failed. | ||
* If the initial connection attempt failed, then wasConnecting will be true. | ||
* | ||
* @param wasConnecting | ||
*/ | ||
public abstract void onDisconnect(boolean wasConnecting); | ||
public abstract void onMessage(String message); | ||
} | ||
|
||
/** | ||
* Initiate a connection attempt. If the connection succeeds, then the | ||
* {@link SocketIOConnectionListener#onConnect() onConnect} will be called. If the connection | ||
* attempt fails, then {@link SocketIOConnectionListener#onDisconnect(boolean) onDisonnect} will | ||
* be called with a value of true. | ||
* @throws IllegalStateException if the socket is not closed. | ||
*/ | ||
void connect(); | ||
|
||
/** | ||
* Initiate a disconnect. This does nothing if the socket is already disconnected or in the | ||
* process of disconnecting. | ||
*/ | ||
void disconnect(); | ||
boolean isOpen(); | ||
|
||
/** | ||
* Return the current socket connection state. | ||
* @return | ||
*/ | ||
ConnectionState getConnectionState(); | ||
|
||
/** | ||
* Send a message. | ||
* | ||
* @param message | ||
* @throws IllegalStateException if the socket is not connected. | ||
*/ | ||
void sendMessage(String message); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/com/glines/socketio/client/jre/SocketIOConnectionImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.glines.socketio.client.jre; | ||
|
||
import com.glines.socketio.client.SocketIOConnection; | ||
|
||
public class SocketIOConnectionImpl implements SocketIOConnection { | ||
|
||
public SocketIOConnectionImpl(SocketIOConnection.SocketIOConnectionListener listener, | ||
String host, short port) { | ||
|
||
} | ||
|
||
@Override | ||
public void connect() { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public void disconnect() { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public ConnectionState getConnectionState() { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
@Override | ||
public void sendMessage(String message) { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters