Mingcong / Twitter_Server

0 stars 0 forks source link

clientID, numFollowers tuple #3

Open huixiangufl opened 9 years ago

huixiangufl commented 9 years ago

case class Order(clientID: Int, numFollowers: String)

object ElevationJsonProtocol extends DefaultJsonProtocol { implicit val orderFormat = jsonFormat2(Order) }

huixiangufl commented 9 years ago

case class FollowerNum(userID: Int, numFollowers: String)

object FollowerNumProtocol extends DefaultJsonProtocol { implicit val followerNumFormat = jsonFormat2(FollowerNum) }

huixiangufl commented 9 years ago

/**

case class FollowerNum(userID: Int, numFollowers: Int)

object FollowerNumProtocol extends DefaultJsonProtocol { implicit val followerNumFormat = jsonFormat2(FollowerNum) }

object Main extends App { implicit val system = ActorSystem("simple-spray-client") import system.dispatcher // execution context for futures below

import FollowerNumProtocol. import SprayJsonSupport. val pipeline = sendReceive ~> unmarshal[FollowerNum] val pipeline2 = sendReceive

println("test")

val responseFuture = pipeline (Get("http://10.227.56.44:8080/getFollowerNum"))

println("test2") println(responseFuture) responseFuture.foreach { response => println(response.userID) println(response.numFollowers) }

println("test3")

var result = pipeline2(Get("http://10.227.56.44:8080/hello")) result.foreach { response => println(s"${response.entity.asString}")

}

// system.shutdown() // system.awaitTermination()

}