Sending message from JAVA to any objects… any best practices ?

May 30, 2012 at 11:54am

Sending message from JAVA to any objects… any best practices ?

Hi there,
I need to send messages from my JAVA/mxj to objects in my patcher.
I keep the reference of those objects (basically they are abstractions called by my MXJ and placed in the patcher)

In each abstraction, I have a kind of central message hub which collects all messages & dispatches them in the abstraction.

I can send the message to objects in the patch directly but it is a bit harder and messy.

How can I send a message to a receive object from JAVA as messnamed can do in JS ?
It would be my best way I guess

#56619
May 30, 2012 at 12:53pm

MaxSystem.sendMessageToBoundObject()

#202956
May 30, 2012 at 12:57pm

Hi jesse,
I fought with patcher, getnamed etc…
I didn’t explored enough MaxSystem part of the tree..

testing that right now :)
many thanks

#202957
May 30, 2012 at 1:07pm

Apparently, my message ideas/system suck.

“(mxj) MaxSystem.sendMessageToBoundObject: Nothing bound to symbol CentralHub_17. Value of s_thing is 0.”

The error message just comes from my ugly design.

My JAVA creates abstractions. 32, for now.
By create I mean, calls. They exist before, the code doesn’t encapsulate them.

I have to be able to send message from my JAVA code to all abstractions.
I created a central hub (basically route + other objects).
The route object has its scripting name changed when the abstraction is instantiated (through #1 arguments)
That part works, but maybe …. I cannot send a message to a route basically :-/

Using JS, I used to use messnamed to send message to receive objects.

any ideas ?

#202958
May 30, 2012 at 1:16pm

ok
found.

basically, I have to do the same and to send my message to the receive object connected to the route hub..

MaxSystem.sendMessageToBoundObject(,…,…)

Jesse, is it the best way for sending message from JAVA ?
best doesn’t make sense.. I mean, is it the way to follow here :p

#202959
May 30, 2012 at 2:08pm

Yes, that’s my understanding.

The “best” practice will vary depending on the design of the system. I’d probably include a [receive all] in each abstraction so that I could address the entire group simultaneously, and a [receive ] to address individual abstractions independently. In this case would be a unique symbol that you give each abstraction.

By doing so you have a tiered system that can address the group together or specific individual abstractions from Java.

#202960
May 30, 2012 at 2:21pm

I like the idea of receive all stuff.
I don’t know how could behave Max in case of … let’s say … 300 objects in which I would send a message like a bang (one per 200 ms maxi for a tempo for instance)
I guess it can hold the charge!

About the localidentifier, I’m doing this already.
My only worries go to the fact I’ll save & retrieve things to & from XML.
I mean, I’ll have to take care of consistencies a lot.
Indeed, imagine that: I’m calling/placing all the abstractions, passing them the unique id as only argument.
I tweak and alter. I remove some object, adding some other… unique id are all ok even if not contiguous obviously.
I save. (and here, how can I take care of that unique id?)
I reload from my preset/xml stuff… all instantiations occur again with the same contiguous id, messing all.

except if I reload that with .. the unique id stored :-p
naughty boy I am!

#202961

You must be logged in to reply to this topic.