aspose file tools*
The moose likes Java in General and the fly likes Help with Chat software Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Help with Chat software" Watch "Help with Chat software" New topic
Author

Help with Chat software

James Hambrick
Ranch Hand

Joined: Sep 04, 2004
Posts: 282

The user gets authenticated just fine, but when I try to send the "user: has joined the us" message to everyone it does not get sent. The tellEveryone method runs and the System.out.println statements work. Also when I try and send a regular message it does not get sent.






Visit my blog! http://jameshambrick.com
Carey Brown
Ranch Hand

Joined: Nov 19, 2001
Posts: 174

I thought this was an interesting topic so I thought I'd see what I could come up with. Here's the results, and it works.





James Hambrick
Ranch Hand

Joined: Sep 04, 2004
Posts: 282

The code looks great but I cannot figure out how to change it up so I can use a GUI. I have been trying to figure what to do so I can use a login window instead of command line most of the day. Nothing seems to work. Any hints/tips on this? Here's the sections of the code I modified

Chat Client
Showing login screen and sending username and password to be authenticated


Chat Server
I am sending to the server the login string "#loginusername/password


ChatServerConnection
It does not compile, doee not like line msg = reader.readline();


Carey Brown
Ranch Hand

Joined: Nov 19, 2001
Posts: 174

Try 'readLine' (upper-case L)
James Hambrick
Ranch Hand

Joined: Sep 04, 2004
Posts: 282

carey brown wrote:Try 'readLine' (upper-case L)


Whoops
sorry!
James Hambrick
Ranch Hand

Joined: Sep 04, 2004
Posts: 282

Here's what I have. The only problem I'm having so far is when I fail to use a proper username password it will not let me try again. I mean I can send a msgbox saying incorrect login and reset the text boxes and set focus on username, but when I try to login again it does not seem to work. Hope this makes sense.







Carey Brown
Ranch Hand

Joined: Nov 19, 2001
Posts: 174

You need two additions: 1) a way for the server to pass back to a specific client if their login attempt passed or failed, 2) a loop in the client to keep prompting until a 'pass' message is received.
James Hambrick
Ranch Hand

Joined: Sep 04, 2004
Posts: 282

carey brown wrote:You need two additions: 1) a way for the server to pass back to a specific client if their login attempt passed or failed, 2) a loop in the client to keep prompting until a 'pass' message is received.


the success or failure of logging in is passed back to the client right now. I just need to work on the loop. Thanks.
James Hambrick
Ranch Hand

Joined: Sep 04, 2004
Posts: 282

Okay I have tweaked the client code now. Before when the login screen was a seperate window it worked fine, but when I make the login screen a dialog box I suddenly cannot login. The server gets the message and login is accepted on the server but the message does not get sent back to the client. The code commented out is that code I used to make the seperate login window work-which makes the program work.

I am only posting the client code, the server code is that same as posted earlier


James Hambrick
Ranch Hand

Joined: Sep 04, 2004
Posts: 282

Okay it's still not working and I've looked over the code the best I can. I have one client program that works and one that does not. The one that works uses a seperate window for the login screen and the other client program uses a dialog box for the login screen. Here the code to it all! I cannot for the life of me figure out why that one does not work. The client sends the login details to the server, the servers authenticates and sends back a response but the client does not recieve the response.

First the client code that works


Now the client code that does not work



Now the server code


And the other server code



James Hambrick
Ranch Hand

Joined: Sep 04, 2004
Posts: 282

Whoops here's the server code did not realize I posted the server connection code twice.
at least I hope this code works, I was trying to use Netbeans to figure this out and seemed to have deleted the code.


 
 
subject: Help with Chat software