Skip to content

Commit

Permalink
Merge pull request akka#23978 from moogpwns/doc-23966-getting-started…
Browse files Browse the repository at this point in the history
…-snppet

Docs - Java snippets for Getting Started Guide Part 4 akka#23966
  • Loading branch information
patriknw authored Nov 17, 2017
2 parents a7b1a66 + 711ac57 commit a5db7bc
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions akka-docs/src/test/java/jdocs/tutorial_4/DeviceGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import jdocs.tutorial_4.DeviceManager;

//#device-group-full
//#device-group-remove
//#device-group-register
public class DeviceGroup extends AbstractActor {
private final LoggingAdapter log = Logging.getLogger(getContext().getSystem(), this);

Expand All @@ -27,11 +29,11 @@ public DeviceGroup(String groupId) {
this.groupId = groupId;
}

//#device-group-register
public static Props props(String groupId) {
return Props.create(DeviceGroup.class, groupId);
}
//#device-group-register
//#device-group-remove

public static final class RequestDeviceList {
final long requestId;
Expand All @@ -50,10 +52,8 @@ public ReplyDeviceList(long requestId, Set<String> ids) {
this.ids = ids;
}
}
//#device-group-remove
//#device-group-register
//#device-group-register
//#device-group-register
//#device-group-remove

final Map<String, ActorRef> deviceIdToActor = new HashMap<>();
//#device-group-register
Expand Down Expand Up @@ -92,10 +92,13 @@ private void onTrackDevice(DeviceManager.RequestTrackDevice trackMsg) {
);
}
}
//#device-group-register
//#device-group-remove

private void onDeviceList(RequestDeviceList r) {
getSender().tell(new ReplyDeviceList(r.requestId, deviceIdToActor.keySet()), getSelf());
}
//#device-group-remove

private void onTerminated(Terminated t) {
ActorRef deviceActor = t.getActor();
Expand All @@ -104,16 +107,21 @@ private void onTerminated(Terminated t) {
actorToDeviceId.remove(deviceActor);
deviceIdToActor.remove(deviceId);
}
//#device-group-register

@Override
public Receive createReceive() {
return receiveBuilder()
.match(DeviceManager.RequestTrackDevice.class, this::onTrackDevice)
//#device-group-register
//#device-group-remove
.match(RequestDeviceList.class, this::onDeviceList)
//#device-group-remove
.match(Terminated.class, this::onTerminated)
//#device-group-register
.build();
}
}
//#device-group-remove
//#device-group-register
//#device-group-remove
//#device-group-full

0 comments on commit a5db7bc

Please sign in to comment.