websocket

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2016 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package websocket manages websocket connections and notifications for Abot clients. This is used by github.com/itsabot/plugin_training to notify trainers of new user messages without requiring page reload.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AtomicWebSocketSet

type AtomicWebSocketSet struct {
	// contains filtered or unexported fields
}

AtomicWebSocketSet maintains open websocket connections with up to one available per user. The uint64 key within the map represents the userID to whom the connection belongs.

func NewAtomicWebSocketSet

func NewAtomicWebSocketSet() AtomicWebSocketSet

NewAtomicWebSocketSet returns an AtomicWebSocketSet to maintain open WebSocket connections on a per-user basis.

func (AtomicWebSocketSet) Get

func (as AtomicWebSocketSet) Get(userID uint64) *websocket.Conn

Get returns a WebSocket connection for a given userID in a thread-safe way.

func (AtomicWebSocketSet) NotifySockets

func (as AtomicWebSocketSet) NotifySockets(c *echo.Context, uid uint64, cmd,
	ret string) error

NotifySockets sends listening clients new messages over WebSockets, eliminating the need for trainers to constantly reload the page.

func (AtomicWebSocketSet) Set

func (as AtomicWebSocketSet) Set(userID uint64, conn *websocket.Conn)

Set a WebSocket connection for a given userID in a thread-safe way.

Jump to

Keyboard shortcuts

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