Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help with Chat software

 
James Hambrick
Ranch Hand
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.





 
Carey Brown
Bartender
Posts: 1686
22
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 1686
22
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try 'readLine' (upper-case L)
 
James Hambrick
Ranch Hand
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
carey brown wrote:Try 'readLine' (upper-case L)


Whoops
sorry!
 
James Hambrick
Ranch Hand
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 1686
22
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic