network

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package network encapsulates functionalities related to network communication. It provides a structure and associated methods to create and parse data frames for messaging across the fusion network protocol ensuring reliability and structure.

Package network encapsulates the logic required to set up network connections and communication, including TCP and TLS encrypted connections, along with handling different types of messages such as text and binary. It uses the fusion network protocol to ensuring reliability and structure.

Index

Constants

View Source
const (
	TCPConnection uint8 = 0x0
	TLSConnection uint8 = 0x1

	TextMessage   uint8 = 0x1
	BinaryMessage uint8 = 0x2
)

Predefined constants for identifying connection and message types.

Variables

This section is empty.

Functions

This section is empty.

Types

type Listener

type Listener struct {
	Cert string
	Key  string

	Ready     func(conn net.Conn)
	Message   func(conn net.Conn, data []byte, opcode uint8)
	Failed    func(conn net.Conn, err error)
	Cancelled func(conn net.Conn)
	// contains filtered or unexported fields
}

Listener struct represents a TCP based connection listener that handles incoming pure TCP connections or TLS encrypted connections.

func (*Listener) Cancel

func (listener *Listener) Cancel()

Cancel stops the listener from accepting new connections and closes any existing ones.

func (*Listener) SendMessage added in v1.4.0

func (listener *Listener) SendMessage(conn net.Conn, messageType uint8, data []byte)

SendMessage sends a message through the specified connection.

func (*Listener) Start

func (listener *Listener) Start(parameter uint8, port uint16) (err error)

Start initiates the listener to start accepting incoming connections on the specified port. The parameter decides whether it's a TCP or TLS connection based on predefined constants.

Jump to

Keyboard shortcuts

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