diff --git a/java/clock-stream/README b/java/clock-stream/README
new file mode 100644
index 0000000..9e4a633
--- /dev/null
+++ b/java/clock-stream/README
@@ -0,0 +1,13 @@
+== About ==
+Simple app stream clock time using websocket.
+
+== How To ==
+git clone https://code.google.com/p/rol3x-place/java/clock-stream/
+mvn jetty:run
+
+With your browser open http://localhost:8080/clock-webapp/clock_client.html
+Open console to view console.log
+Enjoy :)
+
+Ronan-Alexandre Cherrueau
+
diff --git a/opengl/shader/mesh_deformers/main.c b/opengl/shader/mesh_deformers/main.c
index e7177bd..6c925e4 100644
--- a/opengl/shader/mesh_deformers/main.c
+++ b/opengl/shader/mesh_deformers/main.c
@@ -24,6 +24,7 @@
#define AMPLITUDE 0.5
#define FREQUENCY 6.0
+float freq = 1.;
void init()
{
@@ -59,9 +60,11 @@ void display()
draw_cartesian_coordinates();
glColor3f(0.7, 0.7, 1.);
- use_mesh_deformers_shader(AMPLITUDE, FREQUENCY);
+ use_mesh_deformers_shader(AMPLITUDE, freq);
draw_square(10., 4., 500);
+ freq += .005;
+
glutSwapBuffers();
glutPostRedisplay();
}
diff --git a/scala/clock-stream/pom.xml b/scala/clock-stream/pom.xml
index 39c72c8..99f8999 100644
--- a/scala/clock-stream/pom.xml
+++ b/scala/clock-stream/pom.xml
@@ -82,6 +82,16 @@
jetty-websocket
${jetty.version}
+
+ org.eclipse.jetty
+ jetty-webapp
+ ${jetty.version}
+
+
+ org.eclipse.jetty
+ jetty-servlets
+ ${jetty.version}
+
@@ -125,6 +135,155 @@
+
+
+
+
+
+
+
+
+ maven-assembly-plugin
+ 2.3
+
+
+ jar-with-dependencies
+
+
+
+ fr.rol3x.websocket.JettyLauncher
+
+
+
+
+
+ make-assembly
+ package
+
+ single
+
+
+
+
diff --git a/scala/clock-stream/src/main/scala/fr/rol3x/websocket/ClockStreamServlet.scala b/scala/clock-stream/src/main/scala/fr/rol3x/websocket/ClockStreamServlet.scala
index 0616592..ce80d58 100644
--- a/scala/clock-stream/src/main/scala/fr/rol3x/websocket/ClockStreamServlet.scala
+++ b/scala/clock-stream/src/main/scala/fr/rol3x/websocket/ClockStreamServlet.scala
@@ -2,14 +2,14 @@ package fr.rol3x.websocket
import org.eclipse.jetty.websocket.WebSocketServlet
import javax.servlet.http.HttpServletRequest
+import utils.ClockStreamSocket
/**
* Websocket servlet offers service that stream current time.
*
* @author Ronan-Alexandre Cherrueau
*/
-
class ClockStreamServlet extends WebSocketServlet {
override def doWebSocketConnect(request: HttpServletRequest,
- protocol: Nothing) = return ClockStreamSocket
+ protocol: String) = ClockStreamSocket
}
diff --git a/scala/clock-stream/src/main/scala/fr/rol3x/websocket/utils/ClockStreamSocket.scala b/scala/clock-stream/src/main/scala/fr/rol3x/websocket/utils/ClockStreamSocket.scala
index 6adc804..5d7bbe6 100644
--- a/scala/clock-stream/src/main/scala/fr/rol3x/websocket/utils/ClockStreamSocket.scala
+++ b/scala/clock-stream/src/main/scala/fr/rol3x/websocket/utils/ClockStreamSocket.scala
@@ -2,6 +2,7 @@ package fr.rol3x.websocket.utils
import org.eclipse.jetty.websocket.WebSocket
import org.eclipse.jetty.websocket.WebSocket.Connection
+import actors.Actor
/**
* Websocket streams current time.
@@ -9,7 +10,24 @@ import org.eclipse.jetty.websocket.WebSocket.Connection
* @author Ronan-Alexandre Cherrueau
*/
object ClockStreamSocket extends WebSocket {
- private var connections = List[Connection]
+ private var connections = List[Connection]()
+ private val timer = new TimeActor(1000, new Actor {
+ def act {
+ loop {
+ react {
+ case WakeUp =>
+ val timeJSon = """{"hour":"%s", "minute":"%s", "second":"%s"}"""
+ .format(CurrentTime.getHour, CurrentTime.getMinute,
+ CurrentTime.getSecond);
+ connections.foreach{
+ c: Connection => if (c.isOpen) c sendMessage timeJSon
+ }
+ }
+ }
+ }
+ })
+
+ timer.start
override def onOpen(connection: Connection) = {
println("CONNECT [" + connection + "]")
@@ -20,3 +38,20 @@ object ClockStreamSocket extends WebSocket {
println("DISCONNECT [" + closeCode + ":" + message + "]")
}
}
+
+case object WakeUp
+case object Stop
+
+class TimeActor(val timeout: Long, val timerTask: Actor)
+ extends Actor {
+ timerTask.start
+
+ def act {
+ loop {
+ reactWithin(timeout) {
+ case x =>
+ timerTask ! WakeUp
+ }
+ }
+ }
+}
diff --git a/scala/clock-stream/src/main/webapp/WEB-INF/web.xml b/scala/clock-stream/src/main/webapp/WEB-INF/web.xml
index 9f88c1f..90f6aae 100644
--- a/scala/clock-stream/src/main/webapp/WEB-INF/web.xml
+++ b/scala/clock-stream/src/main/webapp/WEB-INF/web.xml
@@ -3,5 +3,14 @@
"http://java.sun.com/dtd/web-app_2_3.dtd" >
- Archetype Created Web Application
+ Archetype Created Web Application
+
+
+ ClockStream
+ fr.rol3x.websocket.ClockStreamServlet
+
+
+ ClockStream
+ /clock-stream/*
+
diff --git a/scala/clock-stream/src/main/webapp/clock_client.html b/scala/clock-stream/src/main/webapp/clock_client.html
index c38169b..e847143 100644
--- a/scala/clock-stream/src/main/webapp/clock_client.html
+++ b/scala/clock-stream/src/main/webapp/clock_client.html
@@ -1,5 +1,55 @@
+
+
+
+ Clock Stream WebSocket
+
+
+
-Hello World!
+Clock Stream WebSocket
+
+ ::
+