[PD] Web interface for PD patch

Edward George ed at suppose.co.uk
Tue Jul 22 17:26:10 CEST 2003


This is very simple to do in java and I have used It many a time in my work,
I generally use netclient object ( from http://www.akustische-kunst.org/ in
the maxlib package ) because it allows very easy 2way comms.

I don't know if you know the code to open a socket in java so here it is
anyway...
Ignore if you do!

You need to 

import java.net.*;




Create the objects

Socket s;
  BufferedReader in;
  PrintWriter so;
  boolean connected;
  

use this code to initiate the connection

try{
      s = new Socket("localhost",3000);
/*obviously change the values above to the ip number on which the pd patch
resides and the port number netclient is listening on*/
      in=new BufferedReader(
      new InputStreamReader(s.getInputStream())
      );
      so=new PrintWriter(s.getOutputStream());
      connected=true;
   }catch(IOException e){println(e);connected=false;}



Then in your java, you can send the values you want like so...

if(connected){
        so.println(values+";");

	//make sure you add the ";" for netclient

        so.flush();

      }


You can simply filter the results in the pd patch for any prefixes you may
use to denote what the value is and is for.




If you wanted to get input from the socket (for two way) you would create a
new thread listening to the port...


class Listener implements Runnable{
  String ln;
public Listener(){}
  public void run(){
    println("running");
    try{
      while((ln=in.readLine())!=null){
        dataCheck(ln);//or whatever method you need
      }
   }catch(IOException e){println(e);}
   }
 }


And start this like so...

l=new Listener();
        t=new Thread(l);
        t.start();



After creating these instances


Listener l;
Thread t;



Hope that makes sense, I quickly copied that code out of various applets so
they just be complete nonsense, I didn't check:)

Otherwise you can use flash creating a socket with xmlSocket (see the flash
documentation) and use the netclient external still.


All the Best,
Ed.


-----Original Message-----
From: pd-list-admin at iem.at [mailto:pd-list-admin at iem.at] On Behalf Of
lists at martinmalm.com
Sent: 22 July 2003 15:09
To: pd-list at iem.kug.ac.at
Subject: [PD] Web interface for PD patch

Hi everyone !

I need to control  a simple PD patch via a webinterface. Since I know a
little bit of Java I would like to use some kind of applet, but I don't
know If this is possible ? What other methods / frameworks would work ?

For this installation I only need oneway WEB -> PD, but it would be fun to
know how to implement two way comunication also.

I would be really happy if someone who has done stuff like this before
could point me in the right direction or maybe provide a simple example.


All the best /

Martin Malm

_______________________________________________
PD-list mailing list
PD-list at iem.at
http://iem.at/cgi-bin/mailman/listinfo/pd-list





More information about the Pd-list mailing list