Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. Do event when variable is modified

Do event when variable is modified

Scheduled Pinned Locked Moved Java
questionsysadmin
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    antonio343
    wrote on last edited by
    #1

    Hi, I've an aplication client-server, and I need to do an event in the client when one variable is modified in the server. it is posible??? I know that in the server or in the client is posible with propertychangelistener, but I don't know if it is posible by this way and how can I do it. Thank you, so much

    T 1 Reply Last reply
    0
    • A antonio343

      Hi, I've an aplication client-server, and I need to do an event in the client when one variable is modified in the server. it is posible??? I know that in the server or in the client is posible with propertychangelistener, but I don't know if it is posible by this way and how can I do it. Thank you, so much

      T Offline
      T Offline
      TorstenH
      wrote on last edited by
      #2

      Yes, you should set up a custom Listener, which is implemented by Server and Client (a common interface should align those implementations). Both should address the listener - the server to launch the event, the client to react on that. Take a look at these links: http://docs.oracle.com/javase/tutorial/rmi/index.html[^] http://www.javacoffeebreak.com/books/extracts/jini/Event.html[^] http://www.karsten-wolke.de/Diplomarbeit/doc/paper.pdf[^] (PDF)

      regards Torsten When I'm not working

      A 1 Reply Last reply
      0
      • T TorstenH

        Yes, you should set up a custom Listener, which is implemented by Server and Client (a common interface should align those implementations). Both should address the listener - the server to launch the event, the client to react on that. Take a look at these links: http://docs.oracle.com/javase/tutorial/rmi/index.html[^] http://www.javacoffeebreak.com/books/extracts/jini/Event.html[^] http://www.karsten-wolke.de/Diplomarbeit/doc/paper.pdf[^] (PDF)

        regards Torsten When I'm not working

        A Offline
        A Offline
        antonio343
        wrote on last edited by
        #3

        If I understood good your answer, I can't implement this, becouse I receive the comunication when the client press a button, but this button only press one client, and not all the client. However, to finish the program I need send an message to all client, but if only press the button one client only receive the message this client and not all. Thank you so much, if I wrong, please check me

        N 1 Reply Last reply
        0
        • A antonio343

          If I understood good your answer, I can't implement this, becouse I receive the comunication when the client press a button, but this button only press one client, and not all the client. However, to finish the program I need send an message to all client, but if only press the button one client only receive the message this client and not all. Thank you so much, if I wrong, please check me

          N Offline
          N Offline
          Nagy Vilmos
          wrote on last edited by
          #4

          There is no reason this can not work, it does on a lot of software. Is the sequence this: 0. A client initiates an action. 1. The action is sent to the server for processing. 2. All clients receive an update with the result. This is a very simple pattern, think live chat rooms via instant messaging.


          Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

          A 1 Reply Last reply
          0
          • N Nagy Vilmos

            There is no reason this can not work, it does on a lot of software. Is the sequence this: 0. A client initiates an action. 1. The action is sent to the server for processing. 2. All clients receive an update with the result. This is a very simple pattern, think live chat rooms via instant messaging.


            Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

            A Offline
            A Offline
            antonio343
            wrote on last edited by
            #5

            Yes, you are right, but I receive the message from the server in the event of press this button, and not all the client press the button. I need an event that run automatic when a value change in the server, becouse not all the client will receive the value changed.

            T 1 Reply Last reply
            0
            • A antonio343

              Yes, you are right, but I receive the message from the server in the event of press this button, and not all the client press the button. I need an event that run automatic when a value change in the server, becouse not all the client will receive the value changed.

              T Offline
              T Offline
              TorstenH
              wrote on last edited by
              #6

              a Listener implementation works both ways. You can have events launched by a client that the server reacts on. And you can have actions the Server launches and one or all client react on. In the consequence you can also have a client launching an event that causes the server to launch an event that all clients react on. Try first to implement some listener action from server to client and vis-a-vis (a console print out should be enough to see if the server(/client ack the event). After that connect the two listener methods and see what fun it can be.

              regards Torsten When I'm not working

              A 1 Reply Last reply
              0
              • T TorstenH

                a Listener implementation works both ways. You can have events launched by a client that the server reacts on. And you can have actions the Server launches and one or all client react on. In the consequence you can also have a client launching an event that causes the server to launch an event that all clients react on. Try first to implement some listener action from server to client and vis-a-vis (a console print out should be enough to see if the server(/client ack the event). After that connect the two listener methods and see what fun it can be.

                regards Torsten When I'm not working

                A Offline
                A Offline
                antonio343
                wrote on last edited by
                #7

                Please, can you show me an example?? Thank you so much!

                T 1 Reply Last reply
                0
                • A antonio343

                  Please, can you show me an example?? Thank you so much!

                  T Offline
                  T Offline
                  TorstenH
                  wrote on last edited by
                  #8

                  This describes the implementation at a simple point: http://java.sys-con.com/node/46979[^]

                  regards Torsten When I'm not working

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups