net

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2019 License: MIT Imports: 1 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Addr

type Addr interface {
	Network() string // name of the network (for example, "tcp", "ws", "wss")
	String() string  // string form of address (for example, "192.0.2.1:25", "domain.name:80")
}

Addr represents a network end point address Copy form std package net to avoid import context and fmt (gopherjs)

type Client

type Client interface {
	// Dial creates connect to the address
	// secureType is a secure connection type
	// 0 - TLS secure with validate certificate | WSS
	// 1 - Secure connection but without validate certificate | Just WS
	// 2 - Insecure without TLS | Just WS
	Dial(secureType int) (Conn, error)
	// EncodeToProto encodes proto msg to bytes
	EncodeToProto(msg interface{}) ([]byte, error)
	// DecodeFromProto decodes proto msg from bytes
	DecodeFromProto(data []byte, dst interface{}) error
	// DecodeRoutes decodes response to _getRoutes request
	// returns Call methods and Notifications
	DecodeRoutes(data []byte) ([]Route, []Route, error)
}

Client is a dialer to server from client side and proto converter

type Conn

type Conn interface {
	// ReadMsg reads message from connect
	ReadMsg() ([]byte, error)
	// WriteMsg wtites message to connect
	WriteMsg([]byte) error

	// RemoteAddr returns the remote network address
	RemoteAddr() Addr
	// LocalAddr returns the local network address.
	LocalAddr() Addr

	// SetReadDeadline sets the deadline for future Read calls
	// and any currently-blocked Read call.
	// A zero value for t means Read will not time out.
	SetReadDeadline(time.Time) error
	// SetWriteDeadline sets the deadline for future Write calls
	// and any currently-blocked Write call.
	// Even if write times out, it may return n > 0, indicating that
	// some of the data was successfully written.
	// A zero value for t means Write will not time out.
	SetWriteDeadline(time.Time) error

	// Close closes the connection.
	// Any blocked Read or Write operations will be unblocked and return errors.
	Close() error
}

Conn like net.Conn for WS or TCP connects on Server side You need to add ReadMsg and WriteMsg to net.Conn interface

type Listener

type Listener interface {
	// Accept accepts new connect
	Accept() (Conn, error)

	// Close closes listener
	Close() error
}

Listener is line net.listener for accept new connects

type Route

type Route interface {
	// GetName returns name of the route
	GetName() string
	// GetHex returns Hex of the route in uint32 representation
	GetHex() uint32
}

Route is a route in server

Directories

Path Synopsis
client
tcp
ws
server
tcp
ws

Jump to

Keyboard shortcuts

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