rpckit

package
v0.0.0-...-9e9b37c Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMsgNotFullySent = errors.New("all the message bytes were not sent - perhaps the message is too large")
View Source
var ErrOverflow = errors.New("Overflow in varint")

Functions

This section is empty.

Types

type Connection

type Connection struct {
	Data interface{}
	// contains filtered or unexported fields
}

func NewConnection

func NewConnection(network, address string, onMessage MessageHandler, onDisconnect DisconnectedHandler) (*Connection, error)

func (*Connection) Close

func (c *Connection) Close() error

Close closes the connection

func (*Connection) RemoteAddr

func (c *Connection) RemoteAddr() net.Addr

func (*Connection) Send

func (c *Connection) Send(msg *Message) error

func (*Connection) String

func (c *Connection) String() string

func (*Connection) Write

func (c *Connection) Write(buf []byte) (int, error)

type ConnectionHandler

type ConnectionHandler func(c *Connection)

type DisconnectedHandler

type DisconnectedHandler func(c *Connection, err error)

type Message

type Message struct {
	LastError error
	// contains filtered or unexported fields
}

func MessageFromBytes

func MessageFromBytes(msg []byte) (*Message, int)

func NewMessage

func NewMessage(capacity int) *Message

func (*Message) Bytes

func (m *Message) Bytes() []byte

func (*Message) ReadFloat64

func (m *Message) ReadFloat64() (float64, error)

func (*Message) ReadInt

func (m *Message) ReadInt() (uint64, error)

func (*Message) ReadString

func (m *Message) ReadString() (string, error)

func (*Message) WriteBytes

func (m *Message) WriteBytes(v []byte)

func (*Message) WriteInt

func (m *Message) WriteInt(v uint64)

func (*Message) WriteString

func (m *Message) WriteString(v string)

type MessageHandler

type MessageHandler func(c *Connection, msg *Message)

type Server

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

func NewServer

func NewServer(onConnection ConnectionHandler, onMessage MessageHandler, onDisconnect DisconnectedHandler) *Server

func NewTestServer

func NewTestServer() *Server

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(network, address string) error

func (*Server) Serve

func (s *Server) Serve(l net.Listener) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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