server

package
Version: v0.0.0-...-7271f6c Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2015 License: MIT Imports: 13 Imported by: 1

Documentation

Overview

The Airdispatch Server framework provides a simple way to create an Airdispatch server.

It defines a common protocol that allows the common code to function without worrying about the storage mechanism of Airdispatch primatives.

Index

Constants

View Source
const (
	Reset      = "\x1b[0m"
	Bright     = "\x1b[1m"
	Dim        = "\x1b[2m"
	Underscore = "\x1b[4m"
	Blink      = "\x1b[5m"
	Reverse    = "\x1b[7m"
	Hidden     = "\x1b[8m"

	FgBlack   = "\x1b[30m"
	FgRed     = "\x1b[31m"
	FgGreen   = "\x1b[32m"
	FgYellow  = "\x1b[33m"
	FgBlue    = "\x1b[34m"
	FgMagenta = "\x1b[35m"
	FgCyan    = "\x1b[36m"
	FgWhite   = "\x1b[37m"

	BgBlack   = "\x1b[40m"
	BgRed     = "\x1b[41m"
	BgGreen   = "\x1b[42m"
	BgYellow  = "\x1b[43m"
	BgBlue    = "\x1b[44m"
	BgMagenta = "\x1b[45m"
	BgCyan    = "\x1b[46m"
	BgWhite   = "\x1b[47m"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicServer

type BasicServer struct {
	ServerDelegate
}

func (BasicServer) HandleError

func (BasicServer) HandleError(err *ServerError)

func (BasicServer) LogMessage

func (BasicServer) LogMessage(toLog ...string)

type Handler

type Handler interface {
	HandlesType(typ string) bool
	HandleMessage(typ string, data []byte, h message.Header, conn net.Conn) ([]message.Message, error)
}

type MessageDescription

type MessageDescription struct {
	Name     string
	Location string
	Nonce    uint64
	// contains filtered or unexported fields
}

func CreateMessageDescription

func CreateMessageDescription(name string, location string, from *identity.Address, to *identity.Address) *MessageDescription

func CreateMessageDescriptionFromBytes

func CreateMessageDescriptionFromBytes(by []byte, h message.Header) (*MessageDescription, error)

func (*MessageDescription) GenerateTransferRequest

func (m *MessageDescription) GenerateTransferRequest() *TransferMessage

func (*MessageDescription) Header

func (m *MessageDescription) Header() message.Header

func (*MessageDescription) ToBytes

func (m *MessageDescription) ToBytes() []byte

func (*MessageDescription) Type

func (m *MessageDescription) Type() string

type MessageList

type MessageList struct {
	Length uint64
	// contains filtered or unexported fields
}

--- Multi-Messages ---

func CreateMessageList

func CreateMessageList(from *identity.Address, to *identity.Address) *MessageList

func CreateMessageListFromBytes

func CreateMessageListFromBytes(b []byte, h message.Header) (*MessageList, error)

func (*MessageList) Header

func (m *MessageList) Header() message.Header

func (*MessageList) ToBytes

func (m *MessageList) ToBytes() []byte

func (*MessageList) Type

func (m *MessageList) Type() string

type Server

type Server struct {
	LocationName string
	Key          *identity.Identity
	Delegate     ServerDelegate
	Handlers     []Handler
	Router       routing.Router
	// Control Channels
	Start chan bool
	Quit  chan bool
}

The server structure tahat holds all of the necessary instance variables

func (*Server) StartServer

func (s *Server) StartServer(port string) error

Function that starts the server on a specific port

type ServerDelegate

type ServerDelegate interface {
	HandleError(err *ServerError)
	LogMessage(toLog ...string)

	SaveMessageDescription(desc *message.EncryptedMessage)

	RetrieveDataForUser(id string, author *identity.Address, forAddr *identity.Address) (*message.EncryptedMessage, io.ReadCloser)
	RetrieveMessageForUser(id string, author *identity.Address, forAddr *identity.Address) *message.EncryptedMessage
	RetrieveMessageListForUser(since uint64, author *identity.Address, forAddr *identity.Address) []*message.EncryptedMessage
}

This interface defines the functions that an Airdispatch server must respond to in order to properly function

type ServerError

type ServerError struct {
	Location string
	Error    error
}

A structure that stores any errors generated by the Server framework

type TransferMessage

type TransferMessage struct {
	Name   string
	Author *identity.Address
	Data   bool
	// contains filtered or unexported fields
}

func CreateTransferMessage

func CreateTransferMessage(name string, from *identity.Address, to *identity.Address, author *identity.Address) *TransferMessage

func CreateTransferMessageFromBytes

func CreateTransferMessageFromBytes(by []byte, h message.Header) (*TransferMessage, error)

func (*TransferMessage) Header

func (m *TransferMessage) Header() message.Header

func (*TransferMessage) ToBytes

func (m *TransferMessage) ToBytes() []byte

func (*TransferMessage) Type

func (m *TransferMessage) Type() string

type TransferMessageList

type TransferMessageList struct {
	Author *identity.Address
	Since  uint64
	// contains filtered or unexported fields
}

func CreateTransferMessageList

func CreateTransferMessageList(since uint64, from *identity.Address, to *identity.Address, author *identity.Address) *TransferMessageList

func CreateTransferMessageListFromBytes

func CreateTransferMessageListFromBytes(by []byte, h message.Header) (*TransferMessageList, error)

func (*TransferMessageList) Header

func (m *TransferMessageList) Header() message.Header

func (*TransferMessageList) ToBytes

func (m *TransferMessageList) ToBytes() []byte

func (*TransferMessageList) Type

func (m *TransferMessageList) Type() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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