Using Sockets to Update Active Users in a Chat

Hello. I am developing a multi-player game for a class using sockets. When a player loads the game, it first opens a GUI that allows the user to enter the hostname, port number of the server and their username. Upon connecting, the user can type into a chat area with other users. Now, i am trying to get the program to keep track of current users connected in a TextArea, but am having problems. Here is my relevent code for the chat.
* Recieves messages from the server
public void run() {
try {
while (true) {
     String line = (i.readUTF ());
outputText.appendText (line + "\n");
} catch (IOException ex) {
ex.printStackTrace ();
} finally {
listener = null;
inputText.hide ();
validate ();
try {
o.close ();
} catch (IOException ex) {
ex.printStackTrace ();
* Handles user interation
public boolean handleEvent (Event e) {
if ((e.target == inputText) && (e.id == Event.ACTION_EVENT)) {
System.out.println(e.target + " " + e.id);
try {
     o.writeUTF (user + ": " + (String) e.arg);
o.flush ();
} catch (IOException ex) {
ex.printStackTrace();
listener.stop ();
inputText.setText ("");
return true;
} else if ((e.target == this) && (e.id == Event.WINDOW_DESTROY)) {
if (listener != null)
listener.stop ();
hide ();
return true;
return super.handleEvent (e);
So what would i do to keep track of the users currently connected in a TextArea. Thanks.

Sorry, I did not see the code format.
     * Recieves messages from the server
    public void run() {
        try {
      while (true) {
       String line = (i.readUTF ());
        outputText.appendText (line + "\n");
    } catch (IOException ex) {
      ex.printStackTrace ();
    } finally {
      listener = null;
      inputText.hide ();
      validate ();
      try {
        o.close ();
      } catch (IOException ex) {
        ex.printStackTrace ();
     * Handles user interation
    public boolean handleEvent (Event e) {
    if ((e.target == inputText) && (e.id == Event.ACTION_EVENT)) {
        System.out.println(e.target + " " + e.id);
      try {
       o.writeUTF (user + ": " + (String) e.arg);
        o.flush ();
      } catch (IOException ex) {
        ex.printStackTrace();
        listener.stop ();
      inputText.setText ("");
      return true;
    } else if ((e.target == this) && (e.id == Event.WINDOW_DESTROY)) {
      if (listener != null)
        listener.stop ();
      hide ();
      return true;
    return super.handleEvent (e);
  }

Similar Messages

  • Using Powershell to update AD Users staring from a CSV

    Hi!
    i need to update a list of AD Users and change for all of them the same attribute with the same value.
    i have a csv containing just the list of users cn, ho can i make the query on this attribute?
    I start to build the command and i've something like that:
    $USERS = Import-CSV C:\Users\Users2.csv
    $USERS | Foreach{Get-ADUser
    -filter {cn -eq $_.name} |
    Set-ADUser -replace @{info=""}
    but i got the following error for every entry in the csv:
    Get-ADUser : Property: 'name' not found in object of type:
    'System.Management.Automation.PSCustomObject'.
    At line:1 char:18
    + $USERS | Foreach{Get-ADUser -filter {cn -eq $_.name}}
    +                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidArgument: (:) [Get-ADUser], ArgumentExcep
       tion
        + FullyQualifiedErrorId : ActiveDirectoryCmdlet:System.ArgumentException,M
       icrosoft.ActiveDirectory.Management.Commands.GetADUser
    something wrong for the filter in the command, someone can help?
    Thanks!

    Added Write-Verbose to help troubleshoot the data being sent to Get-ADUser to make sure that Name actually has data with it.
    Also, the AD module sometimes behaves a little odd when using $_. with the Filter. I've found it better to declare a variable name prior to sending it to the filter like this:
    $USERS = Import-CSV C:\Users\Users2.csv
    $USERS | Foreach{
    Write-Verbose "Name: $($_)" -Verbose
    $Name = $_.Name
    Get-ADUser -filter {cn -eq $Name} | Set-ADUser -replace @{info=""}
    Boe Prox
    Blog |
    Twitter
    PoshWSUS |
    PoshPAIG | PoshChat |
    PoshEventUI
    PowerShell Deep Dives Book

  • Would like to limit application use to one active user...

    I would like to limit the application use to one active user. Is there an easy way to do this without building a custom solution. Also when a different user tries to logon, they will get a message saying that the application is currently in use by the currently active user's name....
    Thanks,
    ML

    Hm,
    I think this could be problematic. You need to think of many things that could happen and take care of those. These postings may help you further:
    Session timeout ?
    Re: Session Timeout Function
    Re: view current active sessions & currently the active user who are logged in
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • How to use Powershell to update user details in Active Directory?

    Hi,
    I received an updated contact list from HR of about 1500 names, and I want to update (make corrections and add missing data) ADUC quickly without having to do each user manually. How would I go about that using power-shell?
    The fields that need updating are:
    Under the General tab -> Description, Telephone number
    Everything under the Address tab
    Under the Telephone tab - > Mobile
    Under the Organization tab -> Job Title, Department, Company, Manager
    The server we're using is Windows Server 2008 R2.
    Many thanks,
    Nick

    There are 100 of such scripts are there online.
    here are few tips and codes. you will get more.  
    https://gallery.technet.microsoft.com/scriptcenter/Feeding-data-to-Active-0227d15c
    http://blogs.technet.com/b/heyscriptingguy/archive/2012/10/31/use-powershell-to-modify-existing-user-accounts-in-active-directory.aspx
    http://powershell.org/wp/forums/topic/ad-import-csv-update-attributes-script/
    Please mark this as answer if it helps

  • How to get active user data using vba code in excel

    Start with this script: http://community.spiceworks.com/scripts/show/1572-list-user-info-in-excel
    Then add an extra line to get the msDS-UserAccountDisabled attribute, or test for it in an If/Else block.

    Could you please help me to get only active user details from active directory using vba code.
    Any help would be immensely appreciated.
    Thanks in advance
    This topic first appeared in the Spiceworks Community

  • Hii all, I just bought an used iphone 5c from an user and only after a few weeks realised that it got activation locked. He might be unaware of that. Is it possible to get back to him and unlock the device for me as i have not contacts with him presently.

    Hii all, I just bought an used iphone 5c from an user and only after a few weeks realised that it got activation locked. He might be unaware of that. Is it possible to get back to him and unlock the device for me as i have not contacts with him presently.

    Well first you need to sync your iPhone 4 with your Mac/PC so that it will transfer all your music, apps, podcasts, etc. Then sync your iPod Touch and the media you selected during the sync should be there on your iPhone. If you have difficulty in transferring media from iPhone to your computer, try softwares like TransCopy. They will help in transferring data from your iphone to your computer. Dont forget to check that all the transferred data is in the iTunes media folder so that the iTunes can locate the files. Link to Transcopy software :
    http://www.copytrans.net/copytrans.php

  • How to know active user in Ad ? & how many days from not use user id ?

    How to know active user in Ad ? & how many days from not use user id ?
    Thanks & Regards, Amol . Amol Dhaygude

    Hi Amol,
    You can use the below command from the command prompt of DC to get all the AD users who are inactive for last
    X weeks,
                                    dsquery
    user -inactive X 
    To extract the inactive user information to a CSV file use the below command,
                   dsquery user -inactive X > c:\TestFolder\InactiveUsers.csv
    NOTE: The value
    X represents number of weeks, for example if your requirement is to find the inactive users for last 90 days then the
    X value should be 13.
    Regards,
    Gopi
    JiJi Technologies

  • Export shared service active users (provision for Hyperion)only using MSAD.

    Hi..
    I m using Hyperion 9.x . and using active directory in shared services.
    while i m using importexport utility to export the active users list with provisioning.
    Issue is :
    Hyperion external authentication have all users of Active directory but i need to export only active users which are provisioned for Hyperion projects .
    I dont need the complete users list .
    Also i m unable to export the provisioning of users in exported file.
    Please can you help me in getting the correct export statement for the above.
    Thank you very much

    Thanks John !!
    I am using the following statement for 9.3.0 but not getting provisioning section in exported file.
    Only users/Groups/Roles are there in exported file.
    Please help me to overcome the problem .
    importexport.css=file:/C:/Hyperion/SharedServices/9.3/AppServer/InstalledApps/WebLogic/8.1/css.xml
    importexport.cmshost=HSS machine name
    importexport.cmsport=58080
    importexport.username=User name **User name i m using is Active Directory user with administrative rights in Hyperion**
    importexport.password=password
    importexport.enable.console.traces=true
    importexport.trace.events.file=C:/Hyperion/common/utilities/CSSImportExportUtility/importexport/trace.log
    importexport.errors.log.file=C:/Hyperion/common/utilities/CSSImportExportUtility/importexport/errors.log
    importexport.locale=en
    # export operations
    export.fileformat=csv
    export.file=C:/export.csv
    export.internal.identities=true
    export.MSAD.user.passwords=true
    export.provisioning.all=true
    export.delegated.lists=false
    export.user.filter=*@MSAD
    export.group.filter=*@MSAD
    export.role.filter=@MSAD
    export.producttype=*
    export.provisioning.apps=*
    Thank you very much
    Vivek Jaiswal
    Edited by: user11966901 on May 25, 2010 8:16 PM
    Edited by: user11966901 on May 25, 2010 8:19 PM
    Edited by: user11966901 on May 25, 2010 8:20 PM

  • Using Update Resource User

    Hi,
    I have a requirement where I need to update a user who is not in IDM but in the resource, I need to update few attributes of this user in LDAP.
    Here is what I am doing to meet this,
    I am calling the subprocess Resource Object Retries where
    op =updateResourceObject,
    objectType=user
    user = user object I builtWhich is most similiar to Out-Of-Box workflow Update Resource User
    My workflow works fine for when the user in windows NT (not in IDM) is updated, but when I am doing this for a user in LDAP, I am getting Objet class violation (error code =65) . I tried passing object class as
    <list>  and  <LIST>   //xml Object  and XPRESS .Still it is the same.
    I need some rescue here.
    I was wondering where is the Out-of-box Update Resource User
    method called.
    If any one has worked , using updateResourceObject service ,
    help me.
    thanks,
    pandu

    Hi pandu345,
    Hint to reduce side effect error - one thing about objectclass violations:
    Consult the directory server error log to see which attribute caused the error!
    In case you modified the schema to be nonconformant to already existing entries you will always get objectclass violations not matter what you try to modify. (I have suffered that already in a non-IdM-but-ldap environment)
    /h

  • How to submit "active users" standard report using shell scripting

    Hi All,
    Greetings.
    I want to submit the "Active Users" standard report in Sysadmin responsibility using a shell script.
    I also want to pass a parameter named email to this..
    can anyone help me do this?
    Thanks in Advance,
    Bhaskar

    Hi Bhaskar,
    You can achieve this by shell scripting either by scripting via CONCSUB utility (invoked from OS) or you can use the FND_SUBMIT package (through PL/SQL package), and in the script itself you can create the outputs or any hardcode messages to a file, and then mail the output to your desired mail address.
    If you use mail or mailx command using the OS utility then you can even send mail to external users which should not necessarily be a registered EBS users.
    Google, Forum Search and metalink will provide you loads of articles on how to use CONCSUB and FND_SUBMIT packages.
    Thanks &
    Best Regards,

  • HT4623 am update my iphone 3gs ios4.1 to ios 6.0.1 using itunes when update comleted itunes show a message Were sorry, we are unable to continue with your activation at this time. Please try again later, or contact customer care! pls help me pls

    am update my iphone 3gs ios4.1 to ios 6.0.1 using itunes when update comleted itunes show a message Were sorry, we are unable to continue with your activation at this time. Please try again later, or contact customer care! pls help me pls

    Generally this is a sign that the iPhone had previously been
    hacked/modified/jailbroken and the update relocked it to the
    original wireless carrier. If this is the case, only that wireless
    carrier can unlock your iPhone. You must contact them to see
    if they offer unlocking and if you qualify.
    Where did you acquire this iPhone?
    What wireless carrier did you use before this problem?
    Does the app Cydia appear on your iPhone?
    What does it say when you look at Settings=>General=>
    About=>Carrier?

  • Using ipone4s, since update to IOS6 I cannot use "search" in the App Store.  I deleted an App because I was have trouble activating certain features since the update to IOS6 - only to find now I cannot download the App to use AT ALL.  ???????

    Using ipone4s, since update to IOS6 I cannot use "search" in the App Store.  I deleted an App because I was have trouble activating certain features since the update to IOS6 - only to find now I cannot download the App to use AT ALL.  ???????

    Anything* >.<

  • Check the number of active users of oc4j in EBS

    Hi,
    I often see a recommndation of sizing jvm's to 1 per 100 active users. How can I find the number of active users currently using a jvm in EBS. We have 4 apps servers and 1 of apps servers also runs OBIEE with it's own jvm.
    I can find out from a unix command prompt counting establish connections to the port but I like to know if there's a better way to find the number of active users using the jvm's
    Thanks
    Mike

    Hi,
    To find the number of active user session on each of the application servers from a unix command line. I would find the port that Apache was listening on eg 8100. The use the following command on each of the apps servers
    netstat -an | grep 8100 | grep -i est | wc -l
    This gives a rough idea of how many active connections are established to the apps server. But I would really like to find how many users are actively using o4cj.
    If you are using forms in socket mode again, you can grep on the forms listening port number to find how many active forms users are connected.
    I can also see how many active connections are in the oc4j established to the database using lsof. Find the process id for oacore jvm.
    lsof -p PID
    But I'm sure there's a better and more accurate way of find active users of o4cj, specifically oacore.
    Thanks
    Mike

  • Help needed for data updation in User Defined Tables

    Hello Experts,
    I am developing one add-on in SAP B1 8.8 to input data in a User Defined Table described as under
    Table Name
    DriverMst UDT Type is No Object
    Description
    Stores the Driver master data which are used to get reference in Sale Delivery Form and Driver data management activity
    User defined fields
    Data Name
    Data source
    Size
    Pane Level
    Description
    Driver Code
    Code
    Alphanumeric
    0
    No object table fixed field
    System Name
    Name
    Alphanumeric
    30
    0
    No object table fixed field
    Full Name
    FullName
    Text
    50
    0
    Father Name
    FatherName
    Text
    50
    0
    Birth Date
    BirthDate
    Date
    0
    Phone Number
    PhoneNo
    Alphanumeric
    50
    0
    Mobile No
    MobileNo
    Alphanumeric
    13
    0
    I have created one form using screen painter displaying text boxes and bind them to the table.
    This form is working absolutely fine when there are some data in table (i.e. Browse using navigation)
    My problem is, when I click add button from tool bar the "OK" button turn to "Add" that means the form is set to Add mode, but when I click "Add" button after entering some data nothing happens and input data is not stored in Table. The same "OK" Button turned to "Update" when I do changes in loaded data, but my changes are not reflected to table after I click "Update".

    Thanks Nagarajan,
    None.
    There is no such query. The table fields is directly linked to Edit Box or Combo Box in form.
    From the examples I learned that I have to do something like this to get my table updated
    Dim oUsrTbl As SAPbobsCOM.UserTable
    Dim Res As Integer
    oUsrTbl = oCompany.UserTables.Item("DRIVERMST")
    oUsrTbl.Code = oBPC.Value 'Item Specific of Driver Code Edit Box
    oUsrTbl.Name = Left(oBPN.Value, 30) 'Item Specific of Name Edit Box
    oUsrTbl.UserFields.Fields.Item("U_FullName").Value = oMFN.Value
    oUsrTbl.UserFields.Fields.Item("U_FatherName").Value = oFTHN.Value
    oUsrTbl.UserFields.Fields.Item("U_BirthDate").Value = oDOB.Value
    oUsrTbl.UserFields.Fields.Item("U_PhoneNo").Value = oPHN.Value
    (Similar For rest ofthe fields)
    Res = oUsrTbl.Add()
    Just let me know that is this necessary to do like above.. To be frank there are few more fields and matrices on the form which I didn't mentioned. I am just trying to get recovered from first step to proceed further.
    Regards

  • Sending file using sockets (difficult)

    Hi, i have the following section of code
    (of which i am not claiming ownership) which
    implements a DCC Send command from irc.
    It accomplishes this using sockets, and while
    i understand how the code accomplishes what it
    does, i need help with a possible modification.
    Basically what i am looking to do is keep track
    of the progress of the send - so that the
    user can at any time see how much of the file
    has been sent and how much is remaining.
    If anyone has done such a thing in the past or
    has a good idea as to how this should be implemented,
    i would be greatful for their help.
    Here is the code:
    new Thread() {
                public void run() {
                    try {
                        ServerSocket ss = new ServerSocket(0);
                        ss.setSoTimeout(timeout);
                        int port = ss.getLocalPort();
                        //byte[] ip = ss.getInetAddress().getAddress();
                        byte[] ip = InetAddress.getLocalHost().getAddress();
                        long ipNum = 0;
                        long multiplier = 1;
                        for (int i = 3; i >= 0; i--) {
                            int byteVal = (ip[i] + 256) % 256;
                            ipNum += byteVal*multiplier;
                            multiplier *= 256;
                        // Rename the filename so it has no whitespace in it when we send it.
                        // .... I really should do this a bit more nicely at some point ....
                        String safeFilename = file.getName().replace(' ', '_');
                        safeFilename = safeFilename.replace('\t', '_');
                        // Send the message to the user, telling them where to connect to in order to get the file.
                        sendCTCPCommand(nick, "DCC SEND " + safeFilename + " " + ipNum + " " + port + " " + file.length());
                        // The client may now connect to us and download the file.
                        Socket socket = ss.accept();
                        socket.setSoTimeout(30000);
                        // Might as well close the server socket now; it's finished with.
                        ss.close();
                        BufferedOutputStream output = new BufferedOutputStream(socket.getOutputStream());
                        BufferedInputStream input = new BufferedInputStream(socket.getInputStream());
                        BufferedInputStream finput = new BufferedInputStream(new FileInputStream(file));
                        byte[] outBuffer = new byte[bufferSize];
                        byte[] inBuffer = new byte[4];
                        int bytesRead = 0;
                        while ((bytesRead = finput.read(outBuffer, 0, outBuffer.length)) != -1) {
                            output.write(outBuffer, 0, bytesRead);
                            output.flush();
                            input.read(inBuffer, 0, inBuffer.length);
                        output.close();
                        input.close();
                        log("+++ DCC SEND Completed to " + nick + " (" + file.getPath() + ")");
                    }

    You already have the necessary code to find the number of bytes sent at any point during the transmission. You can find out the size of the file by instantiating a RandomAccessFile before you send it, and querying for the file length.
    I suggest you make the file size and bytes sent volatile and conveniently accessible to another thread (best implemented here as an inner class?). Your new thread will need to monitor the file transfer at intervals to update the progress indicator. You can generate estimates of time remaining by measuring the average transmission rate, and extrapolating using the total file size. Classically this is done using an average, but you might be better just maintaining a list of fairly recent samples, allowing for the speed swings inherent in internet connections.
    How you update the progress indicator from your monitor thread is up to you. I suggest exposing methods in the UI for setting the progress and time remaining, and simply update them from the monitor.
    Does this help any?

Maybe you are looking for