server

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Connections = make(map[string]*ConnectedClient)

Functions

This section is empty.

Types

type CleanableConnection

type CleanableConnection interface {
	GetConnection() io.ReadWriteCloser
	CleanUp(uid string) error
}

type ConnectedClient

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

func NewConnection

func NewConnection(uid string, conn CleanableConnection) *ConnectedClient

creates new connected client and registers in connections lookup map

func (*ConnectedClient) Close

func (c *ConnectedClient) Close()

func (*ConnectedClient) Read

func (c *ConnectedClient) Read(ctx context.Context, msgCh chan Msg) error

read loop for websocket

func (*ConnectedClient) Write

func (c *ConnectedClient) Write(b []byte) error

write to websocket

type Msg

type Msg struct {
	From string
	Data []byte
}

Msg describes what is read for who

type WebsocketIO

type WebsocketIO interface {
	WriteMessage(c *CleanableConnection, b []byte) error
	ReadMessage(c *CleanableConnection) ([]byte, error)
}
var Server WebsocketIO

make websocket io funcs mockable

Jump to

Keyboard shortcuts

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