sock

package module
v0.0.0-...-71b3261 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2018 License: GPL-3.0 Imports: 5 Imported by: 0

README

Simple Websocket Library For Golang
Documention : https://godoc.org/github.com/Cloraxlan/master-s-sock
GoDoc

Documentation

Overview

Simple Websock Library for Go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ServeWs

func ServeWs(hub *Hub, w http.ResponseWriter, r *http.Request)

ServeWs initializes connection between hub and client

Types

type Client

type Client struct {

	//Use to distinguish connections.
	//Default is 1
	Id int
	// The websocket Connection.
	Conn *websocket.Conn

	// Channel to send to client
	Send chan []byte
	// contains filtered or unexported fields
}

Client is a connection between the server and client

type Hub

type Hub struct {
	// Registered Clients.
	Clients map[*Client]bool

	// Inbound messages from the Clients.
	Messages map[int]string

	// Last Message to Hub
	Input chan MessageBlock
	// contains filtered or unexported fields
}

Connection router that registers connections and handles read/write to them

func NewHub

func NewHub() *Hub

Initializes Hub Struct. Returns *Hub

func (*Hub) Run

func (h *Hub) Run()

Initializes hub cycle

type MessageBlock

type MessageBlock struct {
	//Client that sent Message
	Client *Client
	//The message sent to the server
	Message string
}

MessageBlock is a struct containing a message and a *Client of the client that sent the message

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL