com.illposed.osc
Class OSCPortIn

java.lang.Object
  extended bycom.illposed.osc.OSCPort
      extended bycom.illposed.osc.OSCPortIn
All Implemented Interfaces:
java.lang.Runnable

public class OSCPortIn
extends OSCPort
implements java.lang.Runnable

OSCPortIn is the class that listens for OSC messages.

An example based on com.illposed.osc.test.OSCPortTest::testReceiving() :


        receiver = new OSCPortIn(OSCPort.defaultSCOSCPort());
        OSCListener listener = new OSCListener() {
                public void acceptMessage(java.util.Date time, OSCMessage message) {
                        System.out.println("Message received!");
                }
        };
        receiver.addListener("/message/receiving", listener);
        receiver.startListening();

 

Then, using a program such as SuperCollider or sendOSC, send a message to this computer, port 57110 (defaultSCOSCPort), with the address /message/receiving

Copyright (C) 2004-2006, C. Ramakrishnan / Illposed Software. All rights reserved.

See license.txt (or license.rtf) for license information.

Version:
1.0
Author:
Chandrasekhar Ramakrishnan

Field Summary
protected  OSCByteArrayToJavaConverter converter
           
protected  OSCPacketDispatcher dispatcher
           
protected  boolean isListening
           
 
Fields inherited from class com.illposed.osc.OSCPort
port, socket
 
Constructor Summary
OSCPortIn(int port)
          Create an OSCPort that listens on the specified port.
 
Method Summary
 void addListener(java.lang.String anAddress, OSCListener listener)
          Register the listener for incoming OSCPackets addressed to an Address
 void close()
          Close the socket and free-up resources.
 boolean isListening()
          Am I listening for packets?
 void run()
          Run the loop that listens for OSC on a socket until isListening becomes false.
 void startListening()
          Start listening for incoming OSCPackets
 void stopListening()
          Stop listening for incoming OSCPackets
 
Methods inherited from class com.illposed.osc.OSCPort
defaultSCLangOSCPort, defaultSCOSCPort, finalize
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isListening

protected boolean isListening

converter

protected OSCByteArrayToJavaConverter converter

dispatcher

protected OSCPacketDispatcher dispatcher
Constructor Detail

OSCPortIn

public OSCPortIn(int port)
          throws java.net.SocketException
Create an OSCPort that listens on the specified port.

Parameters:
port - UDP port to listen on.
Throws:
java.net.SocketException
Method Detail

run

public void run()
Run the loop that listens for OSC on a socket until isListening becomes false.

Specified by:
run in interface java.lang.Runnable
See Also:
Runnable.run()

startListening

public void startListening()
Start listening for incoming OSCPackets


stopListening

public void stopListening()
Stop listening for incoming OSCPackets


isListening

public boolean isListening()
Am I listening for packets?


addListener

public void addListener(java.lang.String anAddress,
                        OSCListener listener)
Register the listener for incoming OSCPackets addressed to an Address

Parameters:
anAddress - the address to listen for
listener - the object to invoke when a message comes in

close

public void close()
Close the socket and free-up resources. It's recommended that clients call this when they are done with the port.

Overrides:
close in class OSCPort