Skip to content

paulovenones/go-websocket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-websocket

Overview

go-websocket is a WebSocket server implemented in Go, leveraging concepts such as goroutines, channels, and a WebSocket hub for broadcasting messages. This server allows real-time communication between clients and is designed for a variety of applications, including chat applications, real-time notifications, and more.

Features

  • WebSocket Communication: go-websocket provides WebSocket support, enabling bi-directional, full-duplex communication between clients and the server.
  • Goroutine-Based: The server efficiently manages multiple client connections using goroutines, ensuring scalability and responsiveness.
  • Message Broadcasting: Messages sent by one client can be broadcasted to all connected clients, enabling real-time group communication.

Prerequisites

Before running the go-websocket server, ensure you have the following prerequisites installed:

  • Go: The Go programming language is required to build and run the server.

Installation

To install and run the go-websocket server locally, follow these steps:

  1. Clone the repository to your local machine:
git clone https://github.com/your-username/go-websocket.git
  1. Change into the project directory:
cd go-websocket
  1. Build the server:
go build
  1. Run the server:
./go-websocket

The server will start and listen for WebSocket connections on the specified port (default is 8080).

Usage

Connecting to the Server

Clients can connect to the WebSocket server using the WebSocket URL. For example:

const ws = new WebSocket("ws://your-server-address:8080/ws");

The server will start and listen for WebSocket connections on the specified port (default is 8080).

Usage

Connecting to the Server

Clients can connect to the WebSocket server using the WebSocket URL. For example:

const ws = new WebSocket("ws://your-server-address:8080/ws");

Replace "your-server-address" with the actual address of your go-websocket server.

Sending and Receiving Messages

Once connected, clients can send and receive WebSocket messages using the WebSocket API. Messages can be broadcasted to all connected clients via the server's broadcasting mechanism.

Example Applications

You can build various real-time applications using go-websocket, such as:

  • Chat Applications
  • Real-Time Notifications
  • Live Dashboards
  • Multiplayer Games

Configuration

go-websocket can be configured using environment variables or a configuration file. Details on configuration options and how to set them can be found in the Configuration Documentation (docs/configuration.md).

Contributing

We welcome contributions from the community. If you find a bug or have an idea for an enhancement, please open an issue or submit a pull request following our Contributing Guidelines (CONTRIBUTING.md).

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Gorilla WebSocket: This project uses the Gorilla WebSocket library for WebSocket support.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages