Skip to content

Commit

Permalink
Update version to 1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
velitasali committed Sep 15, 2018
1 parent 800c532 commit 98ea52c
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 119 deletions.
42 changes: 3 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,56 +83,20 @@ public class CommunicationServer extends CoolSocket
}
```

<h3>Implement CoolSocket</h3>
<h4>Maven</h4>

```xml
...
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>bintray-genonbeta-coolsocket</id>
<name>bintray</name>
<url>https://dl.bintray.com/genonbeta/coolsocket</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>bintray-genonbeta-coolsocket</id>
<name>bintray-plugins</name>
<url>https://dl.bintray.com/genonbeta/coolsocket</url>
</pluginRepository>
</pluginRepositories>
<id>bintray</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>bintray</activeProfile>
</activeProfiles>
</profiles
...
```

<h3>Implementing CoolSocket</h3>
<h4>Gradle</h4>

```xml
...
repositories {
...
maven { url "https://dl.bintray.com/genonbeta/coolsocket" }
jcenter()
...
}
...
dependencies {
...
implementation 'com.genonbeta.coolsocket:main:1.0'
implementation 'com.genonbeta.coolsocket:main:1.0.2'
...
}
...
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.genonbeta.coolsocket</groupId>
<artifactId>main</artifactId>
<version>1.0.1.5</version>
<version>1.0.2</version>
<name>CoolSocket</name>
<description>Socket implementation</description>
<url>https://github.com/genonbeta/CoolSocket</url>
Expand Down
42 changes: 31 additions & 11 deletions src/main/java/com/genonbeta/CoolSocket/CoolSocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ public boolean startDelayed(int timeout)
}

// ensures the server is started otherwise returns false
public boolean startEnsured(int timeout) {
public boolean startEnsured(int timeout)
{
long startTime = System.currentTimeMillis();

if (!this.startDelayed(timeout))
Expand Down Expand Up @@ -302,9 +303,19 @@ public static class ActiveConnection
private int mTimeout = NO_TIMEOUT;
private int mId = getClass().hashCode();

public ActiveConnection()
{
this(new Socket());
}

public ActiveConnection(int timeout)
{
this(new Socket(), timeout);
}

public ActiveConnection(Socket socket)
{
this.mSocket = socket;
mSocket = socket;
}

public ActiveConnection(Socket socket, int timeout)
Expand All @@ -313,6 +324,17 @@ public ActiveConnection(Socket socket, int timeout)
setTimeout(timeout);
}

public ActiveConnection connect(SocketAddress socketAddress) throws IOException
{
if (getTimeout() != NO_TIMEOUT)
getSocket().setSoTimeout(getTimeout());

getSocket().bind(null);
getSocket().connect(socketAddress);

return this;
}

@Override
protected void finalize() throws Throwable
{
Expand Down Expand Up @@ -344,7 +366,7 @@ public Socket getSocket()
return this.mSocket;
}

public long getTimeout()
public int getTimeout()
{
return mTimeout;
}
Expand Down Expand Up @@ -488,15 +510,13 @@ public static class Client

public ActiveConnection connect(SocketAddress socketAddress, int operationTimeout) throws IOException
{
Socket socket = new Socket();

if (operationTimeout != NO_TIMEOUT)
socket.setSoTimeout(operationTimeout);

socket.bind(null);
socket.connect(socketAddress);
return new ActiveConnection(operationTimeout)
.connect(socketAddress);
}

return new ActiveConnection(socket, operationTimeout);
public void connect(ActiveConnection connection, SocketAddress socketAddress) throws IOException
{
connection.connect(socketAddress);
}

public Object getReturn()
Expand Down
Loading

0 comments on commit 98ea52c

Please sign in to comment.