Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
Merge pull request #117 from sbalabanov/nailgun.0.9.3_1
Browse files Browse the repository at this point in the history
Nailgun.0.9.3
  • Loading branch information
sbalabanov authored Jan 23, 2018
2 parents 0007cab + be57ec4 commit ee9fb68
Show file tree
Hide file tree
Showing 12 changed files with 655 additions and 504 deletions.
2 changes: 1 addition & 1 deletion nailgun-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>com.martiansoftware</groupId>
<artifactId>nailgun-all</artifactId>
<version>0.9.2-SNAPSHOT</version>
<version>0.9.3-SNAPSHOT</version>
</parent>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@
*/

package com.martiansoftware.nailgun.examples;
import com.martiansoftware.nailgun.NGClientListener;
import com.martiansoftware.nailgun.NGContext;
import com.martiansoftware.nailgun.NGHeartbeatListener;

import java.io.IOException;
import java.io.PrintStream;

/**
* Print one hash per second to standard out while the client is running.
* Print one hash per second to standard out while the client is running.
*
* @author <a href="http://jimpurbrick.com">Jim Purbrick</a>
*/
Expand All @@ -42,21 +39,14 @@ public static void nailMain(final NGContext context) throws IOException {
try {
// Register a new NGClientListener. As clientDisconnected is called from
// another thread any nail state access must be properly synchronized.
context.addClientListener(new NGClientListener() {
public void clientDisconnected() throws InterruptedException {
throw new InterruptedException("Client Disconnected"); // Will interrupt the thread below.
}
});
Thread mainThread = Thread.currentThread();
context.addClientListener(mainThread::interrupt);

// Register a new NGHeartbeatListener. This is normally only used for debugging disconnection problems.
context.addHeartbeatListener(new NGHeartbeatListener() {
public void heartbeatReceived(long intervalMillis) {
context.out.print("H");
}
});
context.addHeartbeatListener(() -> context.out.print("H"));

// Loop printing a hash to the client every second until client disconnects.
while(! Thread.currentThread().isInterrupted()) {
while(!Thread.currentThread().isInterrupted()) {
Thread.sleep(5000);
context.out.print("S");
}
Expand Down
2 changes: 1 addition & 1 deletion nailgun-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>com.martiansoftware</groupId>
<artifactId>nailgun-all</artifactId>
<version>0.9.2-SNAPSHOT</version>
<version>0.9.3-SNAPSHOT</version>
</parent>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ public interface NGClientListener {

/**
* Called by an internal nailgun thread when the server detects that the nailgun client has disconnected.
* {@link NGClientListener}s can be registered using {@link NGContext.registerClientListener}. If
* clientDisconnected throws an InterruptedException nailgun interrupts the main session thread.
* {@link NGClientListener}s can be registered using {@link NGContext#addClientListener}.
*/
public void clientDisconnected() throws InterruptedException;
void clientDisconnected();
}
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,13 @@ public void removeClientListener(NGClientListener listener) {
getInputStream().removeClientListener(listener);
}

/**
* Do not notify about client exit
*/
public void removeAllClientListeners() {
getInputStream().removeAllClientListeners();
}

/**
* @param listener the {@link com.martiansoftware.nailgun.NGHeartbeatListener} to be notified of client events.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ public interface NGHeartbeatListener {
* This can normally be implemented as a no-op handler and is primarily useful for debugging.
* {@link NGClientListener}s can be registered using {@link NGContext.registerHeartbeatListener}.
*/
public void heartbeatReceived(long intervalMillis);
void heartbeatReceived();
}
Loading

0 comments on commit ee9fb68

Please sign in to comment.