Search in sources :

Example 1 with ImmutableHeartbeatPacket

use of me.retrodaredevil.solarthing.type.event.feedback.ImmutableHeartbeatPacket in project solarthing by wildmountainfarms.

the class RequestHeartbeatReceiver method receivePacketGroup.

@Override
public void receivePacketGroup(String sender, TargetPacketGroup packetGroup) {
    Instant now = Instant.now();
    for (Packet packet : packetGroup.getPackets()) {
        if (packet instanceof RequestHeartbeatPacket) {
            RequestHeartbeatPacket requestHeartbeatPacket = (RequestHeartbeatPacket) packet;
            HeartbeatData data = requestHeartbeatPacket.getData();
            OpenSource openSource = new OpenSource(sender, packetGroup.getDateMillis(), requestHeartbeatPacket, requestHeartbeatPacket.getUniqueString());
            ExecutionReason executionReason = new OpenSourceExecutionReason(openSource);
            HeartbeatPacket heartbeatPacket = new ImmutableHeartbeatPacket(data, executionReason);
            eventPacketListReceiverHandler.uploadSimple(now, Arrays.asList(heartbeatPacket));
        }
    }
}
Also used : Packet(me.retrodaredevil.solarthing.packets.Packet) HeartbeatPacket(me.retrodaredevil.solarthing.type.event.feedback.HeartbeatPacket) RequestHeartbeatPacket(me.retrodaredevil.solarthing.commands.packets.open.RequestHeartbeatPacket) ImmutableHeartbeatPacket(me.retrodaredevil.solarthing.type.event.feedback.ImmutableHeartbeatPacket) RequestHeartbeatPacket(me.retrodaredevil.solarthing.commands.packets.open.RequestHeartbeatPacket) HeartbeatData(me.retrodaredevil.solarthing.type.event.feedback.HeartbeatData) OpenSource(me.retrodaredevil.solarthing.type.open.OpenSource) Instant(java.time.Instant) HeartbeatPacket(me.retrodaredevil.solarthing.type.event.feedback.HeartbeatPacket) RequestHeartbeatPacket(me.retrodaredevil.solarthing.commands.packets.open.RequestHeartbeatPacket) ImmutableHeartbeatPacket(me.retrodaredevil.solarthing.type.event.feedback.ImmutableHeartbeatPacket) ExecutionReason(me.retrodaredevil.solarthing.reason.ExecutionReason) OpenSourceExecutionReason(me.retrodaredevil.solarthing.reason.OpenSourceExecutionReason) OpenSourceExecutionReason(me.retrodaredevil.solarthing.reason.OpenSourceExecutionReason) ImmutableHeartbeatPacket(me.retrodaredevil.solarthing.type.event.feedback.ImmutableHeartbeatPacket)

Aggregations

Instant (java.time.Instant)1 RequestHeartbeatPacket (me.retrodaredevil.solarthing.commands.packets.open.RequestHeartbeatPacket)1 Packet (me.retrodaredevil.solarthing.packets.Packet)1 ExecutionReason (me.retrodaredevil.solarthing.reason.ExecutionReason)1 OpenSourceExecutionReason (me.retrodaredevil.solarthing.reason.OpenSourceExecutionReason)1 HeartbeatData (me.retrodaredevil.solarthing.type.event.feedback.HeartbeatData)1 HeartbeatPacket (me.retrodaredevil.solarthing.type.event.feedback.HeartbeatPacket)1 ImmutableHeartbeatPacket (me.retrodaredevil.solarthing.type.event.feedback.ImmutableHeartbeatPacket)1 OpenSource (me.retrodaredevil.solarthing.type.open.OpenSource)1