signalr

package
v0.0.0-...-cd24f0c Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapHub

func MapHub(mux *http.ServeMux, path string, hub HubInterface)

MapHub used to register a SignalR Hub with the specified ServeMux

Types

type ClientProxy

type ClientProxy interface {
	Send(target string, args ...interface{})
}

ClientProxy allows the hub to send messages to one or more of its clients

type Connection

type Connection interface {
	io.Reader
	io.Writer
	ConnectionID() string
}

Connection describes a connection between signalR client and Server

type GroupManager

type GroupManager interface {
	AddToGroup(groupName string, connectionID string)
	RemoveFromGroup(groupName string, connectionID string)
}

GroupManager manages the client groups of the hub

type Hub

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

Hub is a base class for hubs

func (*Hub) Clients

func (h *Hub) Clients() HubClients

Clients returns the clients of this hub

func (*Hub) Groups

func (h *Hub) Groups() GroupManager

Groups returns the client groups of this hub

func (*Hub) Initialize

func (h *Hub) Initialize(ctx HubContext)

Initialize initializes a hub with a HubContext

func (*Hub) OnConnected

func (h *Hub) OnConnected(string)

OnConnected is called when the hub is connected

func (*Hub) OnDisconnected

func (h *Hub) OnDisconnected(string)

OnDisconnected is called when the hub is disconnected

type HubClients

type HubClients interface {
	All() ClientProxy
	Client(connectionID string) ClientProxy
	Group(groupName string) ClientProxy
}

HubClients gives the hub access to various client groups All() gets a ClientProxy that can be used to invoke methods on all clients connected to the hub Client() gets a ClientProxy that can be used to invoke methods on the specified client connection Group() gets a ClientProxy that can be used to invoke methods on all connections in the specified group

type HubContext

type HubContext interface {
	Clients() HubClients
	Groups() GroupManager
}

HubContext is a context abstraction for a hub Clients() gets a HubClients that can be used to invoke methods on clients connected to the hub Groups() gets a GroupManager that can be used to add and remove connections to named groups

type HubInterface

type HubInterface interface {
	Initialize(hubContext HubContext)
	OnConnected(connectionID string)
	OnDisconnected(connectionID string)
}

HubInterface is a hubs interface

type HubLifetimeManager

type HubLifetimeManager interface {
	OnConnected(conn hubConnection)
	OnDisconnected(conn hubConnection)
	InvokeAll(target string, args []interface{})
	InvokeClient(connectionID string, target string, args []interface{})
	InvokeGroup(groupName string, target string, args []interface{})
	AddToGroup(groupName, connectionID string)
	RemoveFromGroup(groupName, connectionID string)
}

HubLifetimeManager is a lifetime manager abstraction for hub instances OnConnected() is called when a connection is started OnDisconnected() is called when a connection is finished InvokeAll() sends an invocation message to all hub connections InvokeClient() sends an invocation message to a specified hub connection InvokeGroup() sends an invocation message to a specified group of hub connections AddToGroup() adds a connection to the specified group RemoveFromGroup() removes a connection from the specified group

type HubProtocol

type HubProtocol interface {
	ReadMessage(buf *bytes.Buffer) (interface{}, bool, error)
	WriteMessage(message interface{}, writer io.Writer) error
	UnmarshalArgument(argument interface{}, value interface{}) error
}

HubProtocol interface

type JsonHubProtocol

type JsonHubProtocol struct {
}

func (*JsonHubProtocol) ReadMessage

func (j *JsonHubProtocol) ReadMessage(buf *bytes.Buffer) (interface{}, bool, error)

func (*JsonHubProtocol) UnmarshalArgument

func (j *JsonHubProtocol) UnmarshalArgument(argument interface{}, value interface{}) error

func (*JsonHubProtocol) WriteMessage

func (j *JsonHubProtocol) WriteMessage(message interface{}, writer io.Writer) error

type Server

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

Server is a SignalR server for one type of hub

func NewServer

func NewServer(hub HubInterface) *Server

NewServer creates a new server for one type of hub

func (*Server) Run

func (s *Server) Run(conn Connection)

Run runs the server on one connection. The same server might be run on different connections in parallel

Jump to

Keyboard shortcuts

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