Code Monkey home page Code Monkey logo

netchat's Introduction

netchat

A small TCP server for handling chat.

Running

$ go run main.go
$ telnet 127.0.0.1 3000
$ telnet 127.0.0.1 3000

Known Bugs

  • If your client receives a message while you are typing, your message is broken up into multiple lines

Approach

The approach I took was largely driven around the main parts of the application that I could see:

  1. The client
  2. The server
  3. The main initialization of the application

main.go is the file that gathers the configurations and starts up the entire applications. server/client.go is the code that drives the behavior for each individual client that connects to the server. In this file you’ll find convenient methods for sends messages and receiving messages from a single client. In server/server.go I wrote the glue to tie many clients together. server.go utilizes all the convenience methods in client.go to broadcast messages to all clients, send messages to singles clients, and relay each client’s messages to all the other clients. I spent a good amount of time really trying to make these boundaries as clean as I could, and I feel like it really paid off in making the code easy to follow.

netchat's People

Contributors

cadebward avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.