bitcoin-atm
bitcoin atm for pyc inc.
git clone https://9o.is/git/bitcoin-atm.git
User.scala
(861B)
1 package inc.pyc.chimera
2 package minions
3
4 import akka.actor._
5 import akka.pattern._
6 import concurrent.Await
7
8 /**
9 * Minion that has access to registered user information.
10 */
11 class UserMinion
12 extends Actor
13 with ActorLogging
14 with Minion
15 with MinionWorker {
16
17 import context.dispatcher
18
19 def props: Props = Props[User]
20 def name: String = "User_"+util.Random.nextInt
21
22 val tasks: Receive = {
23 case address: BitcoinAddress => loginUser(address)
24 case credentials: UserVerify => loginUser(credentials)
25 }
26
27 /**
28 * Logs in registered user.
29 * @param info information details to login
30 */
31 def loginUser[T](creds: T) = workout {
32 worker =>
33 val f = ask(worker, creds).mapTo[Option[UserInfo]]
34 val info = Await.result(f, timeout.duration)
35 if(info.isDefined) sender ! info.get
36 else sender ! LoggedOut
37 }
38 }