[java-dev] Re: Announce: embedded web server for MaxMSP (beta)
Adam Murray
adamjmurray at gmail.com
Wed Jan 16 21:50:37 MST 2008
- Previous message: [java-dev] Announce: embedded web server for MaxMSP (beta)
- Next message: [java-dev] Re: Announce: embedded web server for MaxMSP (beta)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Nice! Thanks Nick, this is great. I had been meaning to try this for a while but never got around to it.
One thing I've wanted to do was to control Max patches from the web. I think using the URL query string would be a good way to do this, but your object doesn't expose that to the patch. So I made a few adjustments...
* In net.loadbang.web.mxj.WebServer
I increased the number of outlets.
declareIO(1, 4);
* In net.loadbang.web.WebServer I added the following code to the top of ReporterHandler.handle() (sorry for the forum messing up my code formatting):
Enumeration params = request.getParameterNames();
while (params.hasMoreElements()) {
String param = (String) params.nextElement();
String[] vals = request.getParameterValues(param);
if (vals == null) {
itsOutputter.output(3, param);
}
else {
StringBuffer s = new StringBuffer(param);
for (int i = 0; i < vals.length; i++) {
s.append(" ").append(vals[i]);
}
itsOutputter.output(3, s.toString());
}
}
// or something like this:
// itsOutputter.output(3, request.getQueryString());
// but I don't feel like doing query string parsing in Max
Then, as a really simple example, you could serve up the following HTML:
<form>
<input type="text" name="text1"><br/>
<input type="text" name="text2"><br/>
<input type="submit">
</form>
To control this patch:
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 376 147 32 196617 print;
#P user textedit 122 212 270 233 32896 3 9;
#P newex 122 186 62 196617 prepend set;
#P user textedit 306 213 454 234 32896 3 9;
#P newex 306 187 62 196617 prepend set;
#P newex 266 138 90 196617 route text1 text2;
#P window setfont Monaco 9.;
#P user umenu 23 42 100 262183 1 64 57 1;
#X add stop;
#X add start;
#P window linecount 2;
#P newex 113 79 214 262153 mxj net.loadbang.web.mxj.WebServer @port 8080 @placeholder web-root;
#P connect 1 1 0 0;
#P connect 2 0 5 0;
#P connect 5 0 6 0;
#P connect 2 1 3 0;
#P connect 3 0 4 0;
#P connect 0 3 7 0;
#P connect 0 3 2 0;
#P window clipboard copycount 8;
If that seems useful to you, might be worth including in your external. It wouldn't take much effort to do something more interactive like using AJAX to update the Max patch on-the-fly (I think there was something like that in the aka.iphone experiements).
It would also be cool to enable JSP support. This could be used to allow the Max patch to communicate back to the browser. I'm not exactly sure how you do that with an embedded Jetty server. I might look into that some other time (unless you already know how?)
BTW, I was not able to use your build.xml file:
$ ant
Buildfile: build.xml
/Users/adam/workspace/net.loadbang.web/MXJ-basis/ant-defs.xml could not be found
BUILD FAILED
java.io.FileNotFoundException: /Users/adam/workspace/net.loadbang.web/MXJ-basis/ant-defs.xml (No such file or directory)
Cheers,
Adam
- Previous message: [java-dev] Announce: embedded web server for MaxMSP (beta)
- Next message: [java-dev] Re: Announce: embedded web server for MaxMSP (beta)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
