comms

package module
v0.0.0-...-3089ce4 Latest Latest
Warning

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

Go to latest
Published: May 28, 2020 License: MIT Imports: 13 Imported by: 3 modules, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

communication

Standard Communication Channels

Use

Documentation

Index

Constants

View Source
const (
	WriteDeadline   = 10 * time.Second
	ReadDeadline    = WriteDeadline
	PongWait        = 60 * time.Second
	PingPeriod      = (PongWait * 9) / 10
	MessageSize     = 4096
	ReadBufferSize  = 1024
	WriteBufferSize = 1024
	InteruptPeriod  = 4 * time.Second
)

These values are used by other Go packages.

Variables

This section is empty.

Functions

func SendGetRequest

func SendGetRequest(url string, res interface{}) error

res: pointer to the instance of response struct

func SendPostRequest

func SendPostRequest(url string, sendBody interface{}, res interface{}) error

sendBody: request body res: pointer to the instance of response struct

Types

type Instance

type Instance struct {
	Id       *uuid.UUID
	Reciever chan interface{}
}

type InstancePool

type InstancePool map[uuid.UUID]*Instance

type Message

type Message struct {
	Success  chan bool
	Reciever *uuid.UUID
	Data     interface{}
}

type Messenger

type Messenger struct {
	Register     chan *Instance
	Unregister   chan *Instance
	UnregisterId chan *uuid.UUID
	Message      chan *Message
	// contains filtered or unexported fields
}

func NewMessenger

func NewMessenger() *Messenger

func (*Messenger) MakeInstance

func (m *Messenger) MakeInstance(rec chan interface{}) *Instance

func (*Messenger) SendMessage

func (m *Messenger) SendMessage(to *uuid.UUID, mes interface{}) bool

func (*Messenger) Start

func (m *Messenger) Start()

type Socket

type Socket interface {
	Reader() chan (interface{})
	Writer() chan (interface{})
	Start(read interface{})
	Close()
}

Socket interface defines how code can interact with the sockets.

func AcceptSocket

func AcceptSocket(w http.ResponseWriter, r *http.Request) (Socket, error)

Use the server types (http) to upgrade a connect to socket. This is the golang paradigm with the gorilla package.

func EstablishSocket

func EstablishSocket(dialurl string) (Socket, error)

Connect to a websocket by the url.

func NewSocket

func NewSocket(conn *websocket.Conn) Socket

Mechanism to convert a connection into a Socket. This can be used by outside packages, but operates as a common final action of the EstablishSocket and AcceptSocket functions.

Jump to

Keyboard shortcuts

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