-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
8 additions
and
19 deletions.
There are no files selected for viewing
19 changes: 4 additions & 15 deletions
19
src/main/java/telraam/logic/positioner/PositionSender.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 |
---|---|---|
@@ -1,31 +1,20 @@ | ||
package telraam.logic.positioner; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import lombok.NoArgsConstructor; | ||
import telraam.websocket.WebSocketMessage; | ||
import telraam.websocket.WebSocketMessageSingleton; | ||
|
||
import java.util.List; | ||
import java.util.logging.Logger; | ||
|
||
public class PositionSender { | ||
private static final Logger logger = Logger.getLogger(PositionSender.class.getName()); | ||
private final ObjectMapper mapper = new ObjectMapper(); | ||
private final WebSocketMessage message = new WebSocketMessage(); | ||
private final WebSocketMessage<List<Position>> message = new WebSocketMessage<>(); | ||
|
||
public PositionSender() { | ||
this.message.setTopic("position"); | ||
} | ||
|
||
public void send(List<Position> position) { | ||
try { | ||
String json = mapper.writeValueAsString(position); | ||
this.message.setData(json); | ||
WebSocketMessageSingleton.getInstance().sendToAll(this.message); | ||
} catch (JsonProcessingException e) { | ||
logger.severe("Json conversion error for \"%s\"".formatted(position.toString())); | ||
} | ||
public void send(List<Position> positions) { | ||
this.message.setData(positions); | ||
WebSocketMessageSingleton.getInstance().sendToAll(this.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