diff --git a/bunti_server/.classpath b/bunti_server/.classpath
index caa5654..245ce4b 100644
--- a/bunti_server/.classpath
+++ b/bunti_server/.classpath
@@ -2,15 +2,11 @@
+
-
-
-
-
-
diff --git a/bunti_server/pom.xml b/bunti_server/pom.xml
index 953ac25..df8645a 100644
--- a/bunti_server/pom.xml
+++ b/bunti_server/pom.xml
@@ -1,10 +1,23 @@
4.0.0
- ctdo
- bunti_server
+ de.ctdo
+ bunti.server
0.0.1-SNAPSHOT
war
+
+
+ 3.0.5.RELEASE
+
+
+
+
+ com.springsource.repository.bundles.release
+ EBR Spring Release Repository
+ http://repository.springsource.com/maven/bundles/release
+
+
+
org.glassfish
@@ -37,8 +50,25 @@
2.4
jdk15
-
-
+
+
+
+ org.springframework
+ spring-core
+ ${org.springframework.version}
+
+
+
+ org.springframework
+ spring-context
+ ${org.springframework.version}
+
+
+
+ org.springframework
+ spring-webmvc
+ ${org.springframework.version}
+
@@ -51,8 +81,36 @@
1.6
-
+
+ http://bunti.ctdo.de:8080/bunti/
+
+ www.ctdo.de
+ Chaostreff Dortmund
+
\ No newline at end of file
diff --git a/bunti_server/src/main/java/de/ctdo/control/BroadcastListener.java b/bunti_server/src/main/java/de/ctdo/control/BroadcastListener.java
new file mode 100644
index 0000000..eed4d1c
--- /dev/null
+++ b/bunti_server/src/main/java/de/ctdo/control/BroadcastListener.java
@@ -0,0 +1,5 @@
+package de.ctdo.control;
+
+public interface BroadcastListener {
+ void Broadcast(String message);
+}
diff --git a/bunti_server/src/main/java/de/ctdo/control/BuntiController.java b/bunti_server/src/main/java/de/ctdo/control/BuntiController.java
new file mode 100644
index 0000000..d786a5e
--- /dev/null
+++ b/bunti_server/src/main/java/de/ctdo/control/BuntiController.java
@@ -0,0 +1,56 @@
+package de.ctdo.control;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sf.json.JSONObject;
+import de.ctdo.dmx.DMXMixer;
+
+public class BuntiController {
+ static BuntiController instance = new BuntiController();
+ DMXMixer mixer = null;
+ protected final List listeners = new ArrayList();
+
+ public static BuntiController getInstance() {
+ return instance;
+ }
+
+ private BuntiController() {
+ mixer = new DMXMixer();
+
+ }
+
+ public void addListener(BroadcastListener l) {
+ synchronized (listeners) {
+ listeners.add(l);
+ }
+ }
+ public void removeListener(BroadcastListener l) {
+ synchronized (listeners) {
+ listeners.remove(l);
+ }
+ }
+
+
+ public void performJSONString(String json) {
+
+ JSONObject jsonobj = JSONObject.fromObject(json);
+
+ if (jsonobj.containsKey("command")) {
+
+ String command = jsonobj.get("command").toString();
+ if (command.equals("setdmxchannels")) {
+
+ } else if (command.equals("switchdevice")) {
+
+ }
+ }
+
+ }
+
+ public void sendBroadcastMessage(String message) {
+ for (BroadcastListener l : listeners) {
+ l.Broadcast(message);
+ }
+ }
+}
diff --git a/bunti_server/src/main/java/de/ctdo/dmx/Mixer.java b/bunti_server/src/main/java/de/ctdo/dmx/DMXMixer.java
similarity index 92%
rename from bunti_server/src/main/java/de/ctdo/dmx/Mixer.java
rename to bunti_server/src/main/java/de/ctdo/dmx/DMXMixer.java
index 2196ef3..f4dfa91 100644
--- a/bunti_server/src/main/java/de/ctdo/dmx/Mixer.java
+++ b/bunti_server/src/main/java/de/ctdo/dmx/DMXMixer.java
@@ -12,14 +12,14 @@ import artnet4j.ArtNetException;
import artnet4j.ArtNetNode;
import artnet4j.packets.ArtDmxPacket;
-public class Mixer {
- static Mixer instance = new Mixer();
+public class DMXMixer {
+
final int TICKS_BETWEEN_DMX_SEND = 20;
final int DMX_MIN_CHANNEL = 0;
final int DMX_MAX_CHANNEL = 512;
final String ARTNET_DEVICE_ADDRESS = "192.168.0.90";
- Logger logger = LoggerFactory.getLogger(Mixer.class);
+ Logger logger = LoggerFactory.getLogger(DMXMixer.class);
int[] dmx512databuffer = new int[512];
static int sequenceID = 0;
ArtNet artnet = new ArtNet();
@@ -28,11 +28,10 @@ public class Mixer {
long ticksLastBufferFlush = 0;
+
protected final List listeners = new ArrayList();
- public static Mixer getInstance() {
- return instance;
- }
+
public void addListener(DMXDataChangedListener l) {
synchronized (listeners) {
listeners.add(l);
@@ -45,7 +44,7 @@ public class Mixer {
}
- private Mixer() {
+ public DMXMixer() {
artnetDmxPacket = new ArtDmxPacket();
artnetDmxPacket.setUniverse(0, 0);
diff --git a/bunti_server/src/main/java/de/ctdo/web/TestController.java b/bunti_server/src/main/java/de/ctdo/web/TestController.java
new file mode 100644
index 0000000..163c5e0
--- /dev/null
+++ b/bunti_server/src/main/java/de/ctdo/web/TestController.java
@@ -0,0 +1,19 @@
+package de.ctdo.web;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.servlet.ModelAndView;
+
+
+@Controller
+public class TestController {
+
+ @RequestMapping("/foobar")
+ public ModelAndView blafasel() {
+
+ ModelAndView mav = new ModelAndView("hello.jsp");
+ return mav;
+
+ }
+
+}
diff --git a/bunti_server/src/main/java/de/ctdo/websocket/BuntiControllerApplication.java b/bunti_server/src/main/java/de/ctdo/websocket/BuntiControllerApplication.java
index a08e055..74f76cf 100644
--- a/bunti_server/src/main/java/de/ctdo/websocket/BuntiControllerApplication.java
+++ b/bunti_server/src/main/java/de/ctdo/websocket/BuntiControllerApplication.java
@@ -9,16 +9,15 @@ import com.sun.grizzly.websockets.WebSocket;
import com.sun.grizzly.websockets.WebSocketApplication;
import com.sun.grizzly.websockets.WebSocketListener;
-import de.ctdo.dmx.Mixer;
+import de.ctdo.control.BuntiController;
public class BuntiControllerApplication extends WebSocketApplication {
Logger logger = LoggerFactory.getLogger(BuntiControllerApplication.class);
@Override
public WebSocket createWebSocket(ProtocolHandler protocolHandler, WebSocketListener... listeners) {
- logger.debug("createSocket ");
BuntiControllerWebSocket socket = new BuntiControllerWebSocket(protocolHandler, listeners);
- Mixer.getInstance().addListener(socket);
+ BuntiController.getInstance().addListener(socket);
return socket;
}
@@ -31,20 +30,14 @@ public class BuntiControllerApplication extends WebSocketApplication {
@Override
public void onClose(WebSocket socket, com.sun.grizzly.websockets.DataFrame frame) {
BuntiControllerWebSocket ws = (BuntiControllerWebSocket) socket;
- Mixer.getInstance().removeListener(ws);
- logger.debug("removed websocket");
+ BuntiController.getInstance().removeListener(ws);
}
@Override
public void onMessage(WebSocket socket, String text) {
- Mixer mixer = Mixer.getInstance();
-
- if(text.startsWith("channel:")) {
- text = text.substring(text.indexOf(":")+1);
- String[] parts = text.split("=");
-
- mixer.setDMX512Channel(Integer.parseInt(parts[0]), Integer.parseInt(parts[1]));
- }
+
+
+ BuntiController.getInstance().performJSONString(text);
// for (final WebSocket webSocket : getWebSockets()) {
diff --git a/bunti_server/src/main/java/de/ctdo/websocket/BuntiControllerServlet.java b/bunti_server/src/main/java/de/ctdo/websocket/BuntiControllerServlet.java
index e6d382f..6c91c36 100644
--- a/bunti_server/src/main/java/de/ctdo/websocket/BuntiControllerServlet.java
+++ b/bunti_server/src/main/java/de/ctdo/websocket/BuntiControllerServlet.java
@@ -10,7 +10,7 @@ import org.slf4j.LoggerFactory;
import com.sun.grizzly.websockets.WebSocketEngine;
-@WebServlet(urlPatterns = "/bunti")
+
public class BuntiControllerServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
Logger logger = LoggerFactory.getLogger(BuntiControllerServlet.class);
@@ -20,13 +20,13 @@ public class BuntiControllerServlet extends HttpServlet {
@Override
public void init(ServletConfig config) throws ServletException {
WebSocketEngine.getEngine().register(app);
- logger.debug("registered");
+ logger.debug("registered BuntiControllerApplication");
}
@Override
public void destroy() {
WebSocketEngine.getEngine().unregister(app);
- logger.debug("unregistered");
+ logger.debug("unregistered BuntiControllerApplication");
}
}
diff --git a/bunti_server/src/main/java/de/ctdo/websocket/BuntiControllerWebSocket.java b/bunti_server/src/main/java/de/ctdo/websocket/BuntiControllerWebSocket.java
index d5bb9fd..4851ca7 100644
--- a/bunti_server/src/main/java/de/ctdo/websocket/BuntiControllerWebSocket.java
+++ b/bunti_server/src/main/java/de/ctdo/websocket/BuntiControllerWebSocket.java
@@ -1,8 +1,5 @@
package de.ctdo.websocket;
-import net.sf.json.JSONArray;
-import net.sf.json.JSONObject;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -10,14 +7,14 @@ import com.sun.grizzly.websockets.DefaultWebSocket;
import com.sun.grizzly.websockets.ProtocolHandler;
import com.sun.grizzly.websockets.WebSocketListener;
-import de.ctdo.dmx.DMXDataChangedListener;
+import de.ctdo.control.BroadcastListener;
/**
* Ein DMXControllerWebSocket gehoert immer zu einem Browserfenster/Tab
* @author lucas
*
*/
-public class BuntiControllerWebSocket extends DefaultWebSocket implements DMXDataChangedListener {
+public class BuntiControllerWebSocket extends DefaultWebSocket implements BroadcastListener {
Logger logger = LoggerFactory.getLogger(BuntiControllerWebSocket.class);
@@ -26,14 +23,21 @@ public class BuntiControllerWebSocket extends DefaultWebSocket implements DMXDat
}
@Override
- public void DMXDataChanged(int[] dmx512data) {
+ public void Broadcast(String message) {
+ // TODO Auto-generated method stub
- JSONArray arr = JSONArray.fromObject(dmx512data);
- JSONObject obj = new JSONObject();
- obj.put("dmx512values", arr);
-
- send(obj.toString());
}
+
+// @Override
+// public void DMXDataChanged(int[] dmx512data) {
+//
+// JSONArray arr = JSONArray.fromObject(dmx512data);
+// JSONObject obj = new JSONObject();
+// obj.put("dmx512values", arr);
+//
+// send(obj.toString());
+// }
+
}
diff --git a/bunti_server/src/main/webapp/WEB-INF/bunti-steuerung.html b/bunti_server/src/main/webapp/WEB-INF/bunti-steuerung.html
new file mode 100644
index 0000000..b132b39
--- /dev/null
+++ b/bunti_server/src/main/webapp/WEB-INF/bunti-steuerung.html
@@ -0,0 +1,96 @@
+
+
+
+
+
+ WebSockets
+
+
+
+
+
+
+
+
+
+
+
+ Hello World!
+
+
+
+
+
+
+
+
+
+
diff --git a/bunti_server/src/main/webapp/WEB-INF/dispatcher-servlet.xml b/bunti_server/src/main/webapp/WEB-INF/dispatcher-servlet.xml
new file mode 100644
index 0000000..c113a78
--- /dev/null
+++ b/bunti_server/src/main/webapp/WEB-INF/dispatcher-servlet.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/bunti_server/src/main/webapp/WEB-INF/web.xml b/bunti_server/src/main/webapp/WEB-INF/web.xml
index 58eb681..3829bba 100644
--- a/bunti_server/src/main/webapp/WEB-INF/web.xml
+++ b/bunti_server/src/main/webapp/WEB-INF/web.xml
@@ -1,31 +1,32 @@
-
- bunti_server
-
- index.html
- index.htm
- index.jsp
- default.html
- default.htm
- default.jsp
-
-
- CTDO bunti control Server
-
-
- 25
-
-
+
+
+ bunti_server
+
+ index.jsp
+
+
+ CTDO bunti control Server
+
+
+ dispatcher
+
+ org.springframework.web.servlet.DispatcherServlet
+
+ 1
+
+
+
+ dispatcher
+ /
+
+
+
+ 25
+
+
\ No newline at end of file
diff --git a/bunti_server/src/main/webapp/hello.jsp b/bunti_server/src/main/webapp/hello.jsp
new file mode 100644
index 0000000..cd9d96f
--- /dev/null
+++ b/bunti_server/src/main/webapp/hello.jsp
@@ -0,0 +1,13 @@
+
+
+ Hello :: Spring Application
+
+
+
+ Hello - Spring Application
+
+ Greetings.
+
+
+
+
\ No newline at end of file
diff --git a/bunti_server/src/main/webapp/index.html b/bunti_server/src/main/webapp/index.html
new file mode 100644
index 0000000..0065564
--- /dev/null
+++ b/bunti_server/src/main/webapp/index.html
@@ -0,0 +1,13 @@
+
+
+
+
+
+ Bla
+
+
+ Hello World!
+
+
+
diff --git a/bunti_server/src/main/webapp/index.jsp b/bunti_server/src/main/webapp/index.jsp
index 0af636a..2a0807d 100644
--- a/bunti_server/src/main/webapp/index.jsp
+++ b/bunti_server/src/main/webapp/index.jsp
@@ -1,97 +1 @@
-<%@page contentType="text/html" pageEncoding="UTF-8"%>
-
-
-
-
-
- WebSockets
-
-
-
-
-
-
-
-
-
-
-
- Hello World!
-
-
-
-
-
-
-
-
-
-
+<% response.sendRedirect("index.html"); %>