udp

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

README

UDP

Provides two sub-packages

  • udps (UDP Server)
  • udpc (UDP Client)

Examples

Documentation

Overview

Package udp provides common functionality used in udpc and udps packages

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorNotConnected = errors.New("not connected")
)

Functions

This section is empty.

Types

type Client

type Client interface {
	// ID
	ID() string
	// Stringify
	String() string
	// Closes the client
	Close(code int, reason string)

	// Sends a Message to the Server
	Send(msg *network.Message) (rmsg *network.Message, err error)
	// Opens a Stream to the Server
	OpenStream(metadata map[string]string, data map[string]string) (stream *Stream, err error)
	// Closes a Stream
	CloseStream(id string)
}

Client Interface stipulates functions which should be present in a client

type Stream

type Stream struct {
	// Stream ID
	Id string

	// Stream Data
	Metadata map[string]string
	// Stream Metadata
	Data map[string]string

	// Exit Channel
	Exit chan bool
	// Closed Status
	Closed bool
	// contains filtered or unexported fields
}

Stream holds the configuration related to a single Stream

func HandleStream

func HandleStream(logger *logrus.Logger, stream quic.Stream, unmarshalers []network.ChannelUnmarshaler) (cstream *Stream, err error)

HandleStream wraps the quic.Stream and provides useful functionality to manage it

func NewStream

func NewStream(metadata map[string]string, data map[string]string, channel *network.Channel) (s *Stream, err error)

Wraps a channel into a Stream and initializes it

func NewStreamFromData

func NewStreamFromData(data *model.StreamConnectionData, channel *network.Channel) *Stream

Wraps a channel into a Stream and does not initialize it This function should be used when the stream is already initialized

func (*Stream) Channel

func (s *Stream) Channel() *network.Channel

Returns the channel associated with the Stream

func (*Stream) Close

func (s *Stream) Close()

Closes the Stream

func (*Stream) Stream

func (s *Stream) Stream() quic.Stream

Returns the Raw Stream

func (*Stream) String

func (s *Stream) String() string

Stringify

type StreamHandler

type StreamHandler func(Client, *Stream)

On New Stream Handler

Directories

Path Synopsis
Package udpc provides functionality to create a UDP Client
Package udpc provides functionality to create a UDP Client
Package udps provides functionality to create a UDP Server
Package udps provides functionality to create a UDP Server

Jump to

Keyboard shortcuts

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