-
Notifications
You must be signed in to change notification settings - Fork 0
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
Krisjanis Veinbahs
committed
Mar 17, 2022
1 parent
c059796
commit 1942ba8
Showing
54 changed files
with
825 additions
and
222 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
backend/domain/src/main/scala/diptestbed/domain/HardwareCameraAuthProjection.scala
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package diptestbed.domain | ||
|
||
import cats.Monad | ||
import cats.implicits._ | ||
import diptestbed.domain.HardwareCameraEvent._ | ||
import diptestbed.domain.HardwareCameraMessage._ | ||
|
||
object HardwareCameraAuthProjection { | ||
def project[F[_]: Monad, A]( | ||
auth: (String, String) => F[Either[String, User]], | ||
send: (A, HardwareCameraMessage) => F[Unit] | ||
)(state: HardwareCameraState[A], event: HardwareCameraEvent[A]): Option[F[Unit]] = { | ||
event match { | ||
case CheckingAuth(username, password) => | ||
Some(auth(username, password).flatMap(_.bimap( | ||
error => send(state.self, AuthFailure(error)), | ||
user => send(state.self, AuthSuccess(user)) | ||
).merge)) | ||
case _ => None | ||
} | ||
} | ||
} |
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
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
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
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
25 changes: 25 additions & 0 deletions
25
backend/domain/src/main/scala/diptestbed/domain/HardwareControlAuthProjection.scala
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package diptestbed.domain | ||
|
||
import cats.Monad | ||
import cats.implicits._ | ||
import diptestbed.domain.HardwareControlEvent._ | ||
import diptestbed.domain.HardwareControlMessageExternalBinary._ | ||
import diptestbed.domain.HardwareControlMessageExternalNonBinary._ | ||
import diptestbed.domain.HardwareControlMessageInternal._ | ||
import diptestbed.domain.HardwareSerialMonitorMessageBinary._ | ||
|
||
object HardwareControlAuthProjection { | ||
def project[F[_]: Monad, A]( | ||
auth: (String, String) => F[Either[String, User]], | ||
send: (A, HardwareControlMessage) => F[Unit] | ||
)(state: HardwareControlState[A], event: HardwareControlEvent[A]): Option[F[Unit]] = { | ||
event match { | ||
case CheckingAuth(username, password) => | ||
Some(auth(username, password).flatMap(_.bimap( | ||
error => send(state.self, AuthFailure(error)), | ||
user => send(state.self, AuthSuccess(user)) | ||
).merge)) | ||
case _ => None | ||
} | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.