Skip to content

wottreng/go_websocket_server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

43f1424 · Sep 9, 2022

History

3 Commits
Sep 9, 2022
Sep 9, 2022
Sep 9, 2022
Sep 9, 2022
Sep 9, 2022
Sep 9, 2022
Sep 9, 2022
Sep 9, 2022
Sep 9, 2022

Repository files navigation

websocket pub/sub microservice

websocket pub/sub style microservice server written in golang

Usage

  • run server: go run server.go
  • connect to the server with arguments ?topic=<some_topic>
  • send messages to the server for that topic
  • receive messages from the server for that topic

Features

  • supports multiple topics
  • supports multiple clients per topic
  • optional api key define in /utils/system_utils/system_utils.go
  • multithreaded
  • cmd line arguments for development(bind to localhost) and production(bind to public address)
  • logging output to file

testing

basic example html served from /test route to test websocket connection

layout

  • server.go: main file
    • starts websocket server
    • contains the handler function
  • file_utils.go: file utilities
    • contains functions to read and write files
  • time_utils.go: time utilities
    • contains functions to get the current time and date
  • http_utils.go: http utilities
    • contains functions to handle http requests
    • contains functions to handle websocket requests
  • system_utils.go: system utilities
    • handles cmd line arguments

websocket server library

  • gorilla websocket
    • Gorilla WebSocket is a Go implementation of the WebSocket protocol.

Cheers, Mark

About

websocket pub/sub style microservice server written in golang

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published