1

I am quite new to Netlogo and I am currently programming a serious game with Hubnet. I was wondering if it is possible to send messages to specific clients via popups windows. I explain: For instance, if a client makes a certain decision (or action), he is alerted of its potential consequences by a message via a popup window. In other situations, I would like the popup window to be a "yes or no" or a multi-choice (with a popup menu) question, in which case I would like to store the client's answer in a specific variable (a global or a turtle variable).

I know that is possible to send popup window messages to the user's interface with for instance:

user-one-of "value" [list-of-choices]

user-message "value"

user-yes-or-no? "value"

I really can't figure out how to do it for the client's interface, however I suspect that it is possible since in some situations, a client may receive a popup message after an action. For instance, when a client enters the wrong input type into an input box (e.g. a character instead of a number), an error message pops up like this:

error message popup in a client's interface

I'd like to program this kind of message by myself in the code so that such a message pops up following some client's actions (for instance when clicking inappropriately a button).

Hope someone can help me on this one!

Thanks!!

Clément

  • 1
    Note that it's possible to write a HubNet client yourself from scratch, that behaves any way you want. Matthew Berland did it for his thesis work, Corey Brady has done it (multiple times, I think), Josh Cough has done it (also multiple times), ando son. In these various efforts the clients were running on a variety of platforms including calculators, Swing apps, Android, etc. Whether this is in the realm of possibility in your situation depends on your level of ambition and level of ability. – Seth Tisue Mar 14 '14 at 19:22
  • Thank you for your comment, it is a good news! I did not find material on the NetLogo website regarding designing a client interface (well, did not search thoroughly but quite a bit). I am still at the prototype stage of the project right now and I am interested in going further (and learning ability is not a limitation :). If some material is available on how to program hubnet client interfaces from scratch, it is more than welcome! The multi-platform option also looks very interesting, we were precisely discussing this point with my colleagues yesterday. – user3349152 Mar 14 '14 at 20:34
  • Why not ask a new question about it? Something like "What resources (documentation, examples, and so forth) are available if I want to build a custom HubNet client?" – Seth Tisue Mar 14 '14 at 21:25

1 Answers1

2

I am going to give three answers to your question. The first, taking your question literally, is "no." It is not possible to trigger a popup window from the host on the HubNet client.

The second is "yes" under certain very limited circumstances. The example you show, suggests you might have an input box on the HubNet client, which the client user will use to send a value up to the host, and which you want to be a NUMERIC value. If, when creating the HubNet client interface, you specifically select "numeric" as they subtype of input, the user who types a non-numeric entry will get a popup box telling them their input is invalid.

The third answer is a kind of "yes" with one of several "workaround" approaches that might be acceptable to you.

For each of these approaches, I'll specifying NetLogo code that would run on the host computer. This code would normally be placed in the part of the model where you have received the objectionable input from the client. Following the format of the HubNet examples in the Models Library, this would be in a procedure called "listen-clients." I'm also assuming that there is a breed of turtles (i'll call them "students") who are mapped to HubNet clients using a turtle variable (I'll call it "user-id"). This user-id would be initially obtained as the hubnet-message-source of the hubnet-enter-message (and of all subsequent messages from that HubNet client).

So, the options I've seen used for the situation you mention (as I understand it) are...

Workaround A, Send a message to the client in one of several ways.

1) send a "chat" message [ probably not acceptable ]

hubnet-send-message user-id "[your message goes here]"

this will show a message in the user's chat window. I think it's not acceptable for you because it is ignore-able, and because it doesn't identify the part of the interface that caused the problem.

2) send a message that overwrites the input box that they have typed the objectionable input into. Suppose the name of the input box on the client is "entry" So then, if the user types "-8" into the input box, and the number must be positive, you could use the following code:

hubnet-send user-id "entry" "MUST BE POSITIVE"

would lead the input box to be filled (startlingly) with that text. (Note: this works even if the input box was declared to be of numeric-only type)

3) cause a message or condition to appear in the VIEW by using hubnet-view-overrides. Depending on how shocking you want the experience to be for the client, you can manipulate their individualized View. (this is for HubNet models that use View Mirroring).

For example, to make the patch at 5 10 show a message "INVALID" you could say:

hubnet-send-override user-id (patch 5 10) "plabel" [ "INVALID" ]

Or you could make it even more crazy by turning ALL the patches red (along with the INVALID message)

hubnet-send-override user-id patches "pcolor" [ red ] 

Then, when the user resolves the issue, you can remove all the view overrides

hubnet-clear-overrides user-id

Option Number 3 is more "advanced" --> i would recommend consulting the User Guide here because the syntax can be confusing. But it is pretty effective in getting users' attention :)

Hope that helps

corey
  • 116
  • 2
  • Thank you Corey for your help. I am a bit sad that Hubnet does not offer the graceful option to send popup windows/questions to clients and I definitely think this kind of functionality would make the excellent hubnet platform even more attractive for real world applications. However, your options #2 and #3 are really good tricks that will do the job in my case. Regarding option #1, I don't know if it is a Mac-related bug, but clients' chat box at the bottom tend to stay masked even when message are sent so I try to avoid using it. – user3349152 Mar 14 '14 at 19:56