relay

package module
v0.0.0-...-f6df368 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2020 License: MIT Imports: 9 Imported by: 0

README

Gitpod Ready-to-Code

go-relayserver

A simple websocket relay server, written in go. It relays incoming stream to multiple connected websockets.

Install

 $ go get github.com/EricNeid/go-relayserver

Usage

 $ go-relayserver optional: -port-stream <port> -port-ws <port> -s <secret>

Testing

Make sure that ffmpeg is in your path.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RecordStream

func RecordStream(stream <-chan *[]byte, path string, file string) <-chan *[]byte

RecordStream write the given stream to file. It returns the stream for further uses.

func StreamToWSClients

func StreamToWSClients(stream <-chan *[]byte, clients <-chan *WsClient)

StreamToWSClients waits for clients to connect and relays the given stream to connected websocket clients. If a client disconnects, it does no longer receives the stream.

Types

type StreamServer

type StreamServer struct {
	InputStream chan *[]byte

	Secret string
	Port   string
	// contains filtered or unexported fields
}

StreamServer represents a server, ready to access a single input stream. To create a new instance use s := newStreamServer(":8080", "MySecret") Before using the server, you need to call s.routes() to configure the routes. To shutdown the server use s.shutdown()

func NewStreamServer

func NewStreamServer(port string, secret string) *StreamServer

NewStreamServer creates new instance of stream server. It is regsitered on the given port and access to stream is protected by given secret.

func (*StreamServer) ListenAndServe

func (s *StreamServer) ListenAndServe()

ListenAndServe starts listening for new stream.

func (*StreamServer) Routes

func (s *StreamServer) Routes()

Routes registers function handler for this SteamServer.

func (*StreamServer) Shutdown

func (s *StreamServer) Shutdown()

Shutdown stops server.

type WsClient

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

WsClient represents a write-only connection to connected websocket.

type WsServer

type WsServer struct {
	IncomingClients chan *WsClient
	Port            string
	// contains filtered or unexported fields
}

WsServer waits for websocket clients to connect.

func NewWebSocketServer

func NewWebSocketServer(port string) *WsServer

NewWebSocketServer creates new server to await websocket connections.

func (*WsServer) ListenAndServe

func (s *WsServer) ListenAndServe()

ListenAndServe starts listening for new websocket connections.

func (*WsServer) Routes

func (s *WsServer) Routes()

Routes configures the routes for the given server.

func (*WsServer) Shutdown

func (s *WsServer) Shutdown()

Shutdown stops the server.

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

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