This file contains hidden or 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
| def greeter: Flow[Message, Message, Any] = | |
| Flow[Message].mapConcat { | |
| case tm: TextMessage => | |
| TextMessage(Source.single("Hello ") ++ tm.textStream ++ Source.single("!")) :: Nil | |
| case bm: BinaryMessage => | |
| // ignore binary messages but drain content to avoid the stream being clogged | |
| bm.dataStream.runWith(Sink.ignore) | |
| Nil | |
| } | |
| val websocketRoute = |
This file contains hidden or 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
| val (wsActor, wsSource) = Source | |
| .actorRef[Message](32, OverflowStrategy.dropNew) | |
| .preMaterialize() | |
| def wsStatusFlow(uuid: String): Flow[Message, Message, Any] = | |
| Flow.fromSinkAndSource(Sink.ignore, wsSource) |
This file contains hidden or 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
| val uploadRoute = | |
| pathPrefix("image") { | |
| path("upload") { | |
| post { | |
| uploadedFile("fileUpload") { | |
| case (_, file) => | |
| val image = ImageIO.read(file) | |
| processImage(image) | |
| complete(StatusCodes.OK) | |
| } |
This file contains hidden or 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
| def processImage(bi: BufferedImage) = Source.single(bi).via(processImageFlow).runWith(Sink.ignore) |
This file contains hidden or 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
| def processImageFlow(): Flow[BufferedImage, ImageProcessed, NotUsed] = | |
| processStage(1) | |
| .via(processStage(2)) | |
| .via(processStage(3)) | |
| .via(processStage(4)) | |
| .map(_ => ImageProcessed("Complete!")) |
This file contains hidden or 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
| def processStage(stageNum: Int) = Flow[BufferedImage] | |
| .async | |
| .delay(1 seconds) | |
| .map(bi => { | |
| println(s"Processing Stage: ${stageNum}") | |
| bi | |
| }) |
This file contains hidden or 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
| const moveEnd = map => { | |
| const bbox = mapBoundsToBbox(map.getBounds()); | |
| setBBox(bbox); | |
| }; | |
| const onLoad = () => { | |
| setMapState({ zoom: [10], loaded: true }); | |
| }; |
This file contains hidden or 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
| const mapBoundsToBbox = bounds => { | |
| const northWest = bounds.getNorthWest(); | |
| const southEast = bounds.getSouthEast(); | |
| const topLeft = { | |
| lat: `${northWest.lat}`, | |
| lon: `${northWest.lng}` | |
| }; | |
| const bottomRight = { | |
| lat: `${southEast.lat}`, | |
| lon: `${southEast.lng}` |
This file contains hidden or 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
| const [bbox, setBBox] = useState({ | |
| topLeft: { | |
| lat: null, | |
| lon: null | |
| }, | |
| bottomRight: { | |
| lat: null, | |
| lon: null | |
| } | |
| }); |
This file contains hidden or 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
| const client = new ApolloClient({ | |
| uri: "http://localhost:8080/graphql" | |
| }); | |
| // inside function App() | |
| return ( | |
| <div className="App"> | |
| <ApolloProvider client={client}> | |
| <Map | |
| {...mapConfig} |