Chat Thingymabobbertron by Korey Fylipek

I used my final project as an opportunity to learn some socket programming, by making a chat client.

What it do:

  • Sends messages
  • Receives Messages
  • Bugs out like crazy
  • Shows everything you type twice

What it don’t:

  • Have a GUI

Current Bugs

  • /me (which should give an output like “KoreusZ is doing a thing”) gives an output like “KoreusZ /me is doing a thing”
  • Disconnecting from a server via the disconnect command makes it spam “null”
  • If someone sends a message while you’re typing, you can’t backspace anything typed before you received the message (this bug is a result of the lack of GUI, something I plan to add in the future)
  • Probably lots more

Now that I’ve summarized it, lets look at a picture of it

Capture

Isn’t that screencap from a controlled environment so nice?

The server is a lot simpler than the client, so let’s talk about that first. Every client gets their own ServerThread, which handles their connection. all the ServerThreads get put into an array, and when a message is Received by the server, exectues this loop to call the same method in each:

//call Message for all instances of ServerThread
for(int i = 1; i < 32; i++){
if(Server.allClients[i] != null){
//call Message for client if there is a client for position i
Server.allClients[i].Message(line);
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *