Client Overrides Example

Client Overrides Example preview image

1 collaborator

Uri_dolphin3 Uri Wilensky (Author)



Tagged by Modeling Commons System over 12 years ago

Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 5.0beta1 • Viewed 287 times • Downloaded 33 times • Run 0 times
Download the 'Client Overrides Example' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)

Comments and Questions

Click to Run Model

breed [students student]

students-own [ user-id ]

patches-own [ true-color ]

to startup

to setup
  ask patches
    ;; the gray covers the "true color" of the patch, which can only
    ;; be seen on the clients if they click on a nearby patch
    set pcolor gray
    set true-color one-of [blue green]

to go
  every 0.1

;; Here's where the action is

to execute-command [command]
  if command = "View"
    ;; extract the coordinates from the message
    let p patch (item 0 hubnet-message) (item 1 hubnet-message)
    ;; get the patch clicked on and the surrounding patches in a single patch set
    let my-patch-set (patch-set p [neighbors] of p)

    ;; clear any existing overrides on the client including any patches
    ;; revealed by the last click
    hubnet-clear-overrides hubnet-message-source
    ;; send an override to the client each patch in MY-PATCH-SET will evaluate
    ;; the reporter in the block [TRUE-COLOR].  So the color of the patch on the client
    ;; will appear as TRUE-COLOR rather than the color on the server.
    hubnet-send-override hubnet-message-source my-patch-set "pcolor" [true-color]

;; Standard HubNet Procedures

to listen-clients
  while [hubnet-message-waiting?]
    ifelse hubnet-enter-message? ;; when clients enter we get a special message
    [ create-new-student ]
      ifelse hubnet-exit-message? ;; when clients exit we get a special message
      [ remove-student ]
      [ ask students with [user-id = hubnet-message-source]
        [ execute-command hubnet-message-tag ]

to create-new-student
  create-students 1
    set user-id hubnet-message-source

to remove-student
  ask students with [user-id = hubnet-message-source]
  [ die ]

; Public Domain:
; To the extent possible under law, Uri Wilensky has waived all
; copyright and related or neighboring rights to this model.

There are 3 versions of this model.

Uploaded by When Description Download
Uri Wilensky about 11 years ago Updated to NetLogo 5.0.4 Download this version
Uri Wilensky over 11 years ago Updated version tag Download this version
Uri Wilensky over 12 years ago Updated from NetLogo 5.0 Download this version

Attached files

File Type Description Last updated
Client Overrides Example.png preview Preview for 'Client Overrides Example' about 11 years ago, by Uri Wilensky Download

This model does not have any ancestors.

This model does not have any descendants.