Re: HELP! Updating a 'global' variable in a chat application

From: Anthony Borla (ajborla_at_bigpond.com)
Date: 12/09/03


Date: Tue, 09 Dec 2003 06:35:05 GMT


"E-Wiz" <sonique55107@yahoo.com> wrote in message
news:9e6e0c61.0312081604.18c82483@posting.google.com...
>
> I am having trouble with an application i am building and
> would love any helping hands.
>
> Here's what i am trying to do:
>
> I have a chat application that works with sockets.
>
> I want the admin to have access to a variable that is specific
> to each person in the chatroom. To be more specific, I define
> a variable x as follows:
>
> public class Global {
> public static int x =0;
> }
>
> And then i want to update x through the following
> method:
>
> public void doAction(ActionEvent event)
> {
> if (event.getSource() == initializeButton)
>
> {
> Global.x=1;
> }
> ......
>

By declaring this variable 'static' you are ensuring there is a single copy
of it shared by all instances of this class. If one instance updates it, the
previous value - for all instances - is overwritten. However, this is not
the source of your problem.

>
> Well, this compiles but the admin only has access to his/her
> own x. So when i click on initializeButton, only the admin's
> instance of x changes. Is there a way to have ALL instances
> of x changing? Or user y's instance of x changing?
>

This is not the way to share data amongst a group of programs.

I'm assuming the administrator is using a client program, as are the other
users, to access the 'chat server'. Now, since the server is accessed by
all, *it* should be the location any client information the administrator
must access should be stored.

So, for example, the server might host an array, or 'ArrayList' [or similar]
of permanent user data, perhaps another of logged in user data [or the two
may be combined by not having all fields filled]. Of course, only the
administrator would be granted access to such data.

If this is not clear may I suggest reading up on client / server
applications. A useful tutorial might be:

    http://java.sun.com/docs/books/tutorial/networking/index.html

as would:

    http://java.sun.com/docs/books/tutorial/together/index.html

I hope this helps.

Anthony Borla



Relevant Pages

  • Re: Problem with connect computer wizard
    ... You mentioned that you're using Anonymous access with Administrator ... Open ConnectComputer properties in IIS. ... And there is only the DNS server be configured on client ...
    (microsoft.public.windows.server.sbs)
  • Re: RWW no longer working for client desktops
    ... client and run http://>/remote and see if the behavior is the ... So you get the Web Edition banner; after that, can you log in, and if so, do ... If you log in to RWW as the Administrator, ... when given the choice between logging into the server ...
    (microsoft.public.windows.server.sbs)
  • RE: SBS 2003 ConnectComputer
    ... Are you logged on locally as an administrator and using the domain admin to ... Microsoft SBS Product Support ... | client machine and proceeds. ...
    (microsoft.public.windows.server.sbs)
  • RE: Server does not send faxes for non-administrators
    ... This has been the situation since I set the server up in April. ... a fax as an administrator from any client and from the console. ... I understand that only Administrator can fend fax the other users cannot. ... word to the Newsgroup for accurate research. ...
    (microsoft.public.windows.server.sbs)
  • Re: client DIS"connect"
    ... Or do you not wish to store user data on the SBS or ??? ... directions will install the client connect application on the client ... modifications and additions) to the server. ...
    (microsoft.public.windows.server.sbs)