name: Chat Room

sort: 1

Chat Room

This demo shows two ways of implementing a Web Instant Messaging application:

Using long polling. Using WebSocket.

Both of them save data in memory by default so everything will be lost every time the application restarts, but you can change this setting in conf/app.conf to enable a database adapter for data persistence.

Here is the project structure:

  1. WebIM/
  2. WebIM.go # File of main package
  3. conf
  4. app.conf # Configuration file
  5. controllers
  6. app.go # The welcome screen that allows the user to pick a technology and username
  7. chatroom.go # Functions for data management
  8. longpolling.go # Controller and methods for long polling chat demo
  9. websocket.go # Controller and methods for WebSocket chat demo
  10. models
  11. archive.go # Functions of chat data operations for both demos.
  12. views
  13. ... # Template files
  14. static
  15. ... # JavaScript and CSS files

Browse the code on GitHub