Skip to content
This repository has been archived by the owner on Mar 13, 2019. It is now read-only.

Commit

Permalink
scrooge + websocket integration
Browse files Browse the repository at this point in the history
  • Loading branch information
MasseGuillaume committed Sep 28, 2013
1 parent 19f9ed7 commit 5c0b8ec
Show file tree
Hide file tree
Showing 22 changed files with 146 additions and 295 deletions.
4 changes: 0 additions & 4 deletions README
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
This is your new Play 2.1 application
=====================================

This file will be packaged with your application, when using `play dist`.
11 changes: 0 additions & 11 deletions app/Global.scala

This file was deleted.

25 changes: 9 additions & 16 deletions app/controllers/Application.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ import akka.util.Timeout
import akka.pattern.ask

import model._

import ca.polymtl.log4900.eval.Add
import ca.polymtl.log4900.eval.MathResult
import ca.polymtl.log4900.eval.AddResult
import ca.polymtl.log4900.api._

object Application extends Controller {
implicit val timeout = Timeout(5 seconds)
Expand All @@ -31,18 +28,14 @@ object Application extends Controller {
val (enumerator, channel) = Concurrent.broadcast[JsValue]

val in = Iteratee.foreach[JsValue](content => {
val op1 = (content \ "op1").as[Int]
val op2 = (content \ "op2").as[Int]

(LookupApplication.actor ? Add(1, 1)).mapTo[MathResult] onComplete {
case(e) => println("fail")
}
// } onSuccess {
// case AddResult(o1,o2,res) => println(s"$o1 + $o2 = $res")
// }
})

val firstName = (content \ "firstName").as[String]
val lastName = (content \ "lastName").as[String]

EvalService.client.hello(User(firstName, lastName)).map(r => {
println(r)
channel.push(JsObject(Seq("response" -> JsString(r))))
})
})
(in, enumerator)
}

}
50 changes: 0 additions & 50 deletions app/model/Calculator.scala

This file was deleted.

18 changes: 18 additions & 0 deletions app/model/EvalService.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package model;

import ca.polymtl.log4900.api._

import com.twitter.finagle._
import builder.ClientBuilder
import thrift.ThriftClientFramedCodec

object EvalService {

private lazy val service = ClientBuilder()
.hosts(s"${Config.host}:${Config.port}")
.codec(ThriftClientFramedCodec())
.hostConnectionLimit(1)
.build()

lazy val client = new HelloUser.FinagledClient(service)
}
6 changes: 4 additions & 2 deletions app/views/index.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

@main("Hey") {
<form action="@routes.Application.eval.webSocketURL()">
<input name="op1"> + <input name="op2">
<p>say hi</p>
<input name="firstName">
<input name="lastName">
<input type="submit">
<span class="result"></span>
<span class="result">result</span>
</form>
}{
<script src="@routes.Assets.at("javascripts/chat.js")"></script>
Expand Down
71 changes: 1 addition & 70 deletions conf/application.conf
Original file line number Diff line number Diff line change
@@ -1,74 +1,5 @@
# This is the main configuration file for the application.
# ~~~~~

# Secret key
# ~~~~~
# The secret key is used to secure cryptographics functions.
# If you deploy your application to several instances be sure to use the same key!
application.secret="8aM/[QwT<[40sWC;l^LXDMBDciBjC7inppKGfJkr?ffYDNd=ralJ9uUggtTBEC23"

# The application languages
# ~~~~~
application.langs="en"

# Global object class
# ~~~~~
# Define the Global object class for this application.
# Default to Global in the root package.
# application.global=Global

# Router
# ~~~~~
# Define the Router object to use for this application.
# This router will be looked up first when the application is starting up,
# so make sure this is the entry point.
# Furthermore, it's assumed your route file is named properly.
# So for an application router like `my.application.Router`,
# you may need to define a router file `conf/my.application.routes`.
# Default to Routes in the root package (and conf/routes)
# application.router=my.application.Routes

# Database configuration
# ~~~~~
# You can declare as many datasources as you want.
# By convention, the default datasource is named `default`
#
# db.default.driver=org.h2.Driver
# db.default.url="jdbc:h2:mem:play"
# db.default.user=sa
# db.default.password=""

# Evolutions
# ~~~~~
# You can disable evolutions if needed
# evolutionplugin=disabled

# Logger
# ~~~~~
# You can also configure logback (http://logback.qos.ch/), by providing a logger.xml file in the conf directory .

# Root logger:
logger.root=ERROR

# Logger used by the framework:
logger.play=INFO

# Logger provided to your application:
logger.application=DEBUG

calculator {
include "common"

akka {
# LISTEN on tcp port 2552
remote.netty.tcp.port = 2552
}
}

remotelookup {
include "common"

akka {
remote.netty.tcp.port = 2553
}
}
logger.application=DEBUG
21 changes: 0 additions & 21 deletions conf/common.conf

This file was deleted.

2 changes: 0 additions & 2 deletions conf/routes
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
GET / controllers.Application.index
GET /eval controllers.Application.eval


GET /assets/*file controllers.Assets.at(path="/public", file)
GET /webjars/*file controllers.WebJarAssets.at(file)
6 changes: 6 additions & 0 deletions modules/api/src/main/java/ca.polymtl.log4900.api/Config.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package ca.polymtl.log4900.api;

public class Config {
public static final String host = "localhost";
public static final int port = 8001;
}
10 changes: 10 additions & 0 deletions modules/api/src/main/thrift/ca.polymtl.log4900.api/api.thrift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace scala ca.polymtl.log4900.api

struct User {
1: string firstName,
2: string lastName
}

service HelloUser {
string hello(1: User user)
}
16 changes: 0 additions & 16 deletions modules/eval/src/main/resources/application.conf

This file was deleted.

21 changes: 0 additions & 21 deletions modules/eval/src/main/resources/common.conf

This file was deleted.

Loading

0 comments on commit 5c0b8ec

Please sign in to comment.