talkserver

package
v0.0.0-...-cde1217 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthWithKey

func AuthWithKey(key string) func(msg []byte) ([]byte, bool)

AuthWithKey is an auth function that If the key is an empty string it will panic This returns a function that can be used as Options.Auth

func Setup

func Setup(r *gin.Engine, o ...Options)

Setup sets up the needed routes and sets up the websocket route

Types

type Options

type Options struct {
	// Auth validates the request, if this is not defined it will broadcast every message
	// The function it's argument is the message that websocket reciefed
	// The return values are the message that gets send to all other client
	// And a bool that tells if the Auth was correct
	Auth func(msg []byte) ([]byte, bool)

	// if SendKeepAlive is true the server will send a keep alive message every 30 seconds
	// the message is "🤖️"
	SendKeepAlive bool

	// if ExtendURL is spesified the middleware will extends another middleware
	ExtendURL   string
	ExtendWSURL string
}

Options are some settings to include in the Setup function

Jump to

Keyboard shortcuts

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