go_wsocket

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: MIT Imports: 9 Imported by: 0

README

go_wsocket

implementación minima del protocolo WebSocket en Go utilizando solo librería http standard

solo 2 dependencias:


  • github.com/cdvelop/go_model

  • github.com/gorilla/websocket


para uso general chat o x sistema. en la carpeta test hay un ejemplo de su uso.

saludos

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WebSocket

type WebSocket struct {

	//canal de entrada nuevas solicitudes.
	REQUESTS_IN chan *model.Request

	// canal salida de solicitudes
	REQUESTS_OUT chan *model.Request

	// canal que avisa el cierre de las conexiones
	CLOSED_CONNECTION chan *model.Applicant
	// contains filtered or unexported fields
}

concentrador de solicitantes para websocket

func New

func New(buffer_size, concurrency_max int, allowed_origins ...string) *WebSocket

allowed_origins ej: "http://localhost", "http://127.0.0.1", "http://example.com", "https://example.com" buffer_size ej: 1024 concurrency_max Limitar la concurrencia de conexiones simultáneas ej 100

func (*WebSocket) ApplicantAdd

func (h *WebSocket) ApplicantAdd(applicants ...*model.Applicant)

func (*WebSocket) ApplicantRemove

func (hub *WebSocket) ApplicantRemove(a *model.Applicant)

func (*WebSocket) ServeHTTP

func (h *WebSocket) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*WebSocket) StartBroadcasting

func (h *WebSocket) StartBroadcasting(in <-chan *model.Request)

Jump to

Keyboard shortcuts

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