hi,thanks for sharing!
Just tried Multicast way to let
MulticastA and
MulticastB communicate with each other. in computer, they works very well.
But when build
MulticastA to Processing for Android emulator, and leave
MulticastB in computer, they did not work.(already set up the network permissions)
i really have no idea to let them work,,,,any feedback will be really helpful. thanks so much!
MulticastA
- // Requirements
- // * oscP5 (http://www.sojamo.de/libraries/oscP5/)
- import oscP5.*;
- import netP5.*;
- OscP5 oscP5;
- void setup() {
- size(400,400);
- oscP5 = new OscP5(this, "239.0.0.1", 7777);
- }
- void draw() {
- background(0);
- }
- void mousePressed() {
- OscMessage myOscMessage = new OscMessage("/test/0/state");
- myOscMessage.add(1);
- oscP5.send(myOscMessage);
- }
- void mouseReleased() {
- OscMessage myOscMessage = new OscMessage("/test/0/state");
- myOscMessage.add(0);
- oscP5.send(myOscMessage);
- }
- // Requirements
- // * oscP5 (http://www.sojamo.de/libraries/oscP5/)
- import oscP5.*;
- import netP5.*;
- OscP5 oscP5;
- void setup() {
- size(400,400);
- oscP5 = new OscP5(this, "239.0.0.1", 7777);
- }
- void draw() {
- //
- }
- void oscEvent(OscMessage theOscMessage) {
- // /test/*/stateにマッチ
- if (theOscMessage.addrPattern().matches("/test/\\*/state")) {
- println("id: *");
- }
- // /test/0/stateや/test/1/stateなど任意の数字を持つパターンにマッチ
- if (theOscMessage.addrPattern().matches("/test/[0-9]*/state")) {
- // /test/0/stateを/でsplitした場合の結果は以下のようになる
- // [0] ""
- // [1] "test"
- // [2] "0"
- // [3] "state"
- int id = Integer.parseInt(theOscMessage.addrPattern().split("/")[2]);
- if (theOscMessage.checkTypetag("i")) {
- int value = theOscMessage.get(0).intValue();
- println("id: " + id + ", value: " + value);
- if (value == 1) {
- background(255);
- }
- else if (value == 0) {
- background(0);
- }
- }
- }
- }