event

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2019 License: MIT Imports: 2 Imported by: 10

Documentation

Index

Constants

View Source
const (
	StatusRequest        = Type("StatusRequest")
	ProtocolEngineStatus = Type("ProtocolEngineStatus")

	PeerRequest = Type("PeerRequest")

	// Blocking Events both Block and Unblock have the same structure
	// attributes:
	// RemotePeer: [eg "chpr7qm6op5vfcg2pi4vllco3h6aa7exexc4rqwnlupqhoogx2zgd6qd"
	BlockPeer   = Type("BlockPeer")
	UnblockPeer = Type("UnblockPeer")

	JoinServer = Type("JoinServer")

	ProtocolEngineStartListen = Type("ProtocolEngineStartListen")
	ProtocolEngineStopped     = Type("ProtocolEngineStopped")

	InvitePeerToGroup = Type("InvitePeerToGroup")

	// a group invite has been received from a remote peer
	// attributes:
	// TimestampReceived [eg time.Now().Format(time.RFC3339Nano)]
	// RemotePeer: [eg "chpr7qm6op5vfcg2pi4vllco3h6aa7exexc4rqwnlupqhoogx2zgd6qd"]
	// GroupInvite: [eg "torv3....."]
	NewGroupInvite = Type("NewGroupInvite")

	// GroupID
	AcceptGroupInvite = Type("AcceptGroupInvite")

	SendMessageToGroup = Type("SendMessagetoGroup")

	//Ciphertext, Signature:
	EncryptedGroupMessage = Type("EncryptedGroupMessage")
	//TimestampReceived, TimestampSent, Data(Message), GroupID, Signature, PreviousSignature, RemotePeer
	NewMessageFromGroup = Type("NewMessageFromGroup")

	// an error was encountered trying to send a particular Message to a group
	// attributes:
	// GroupServer: The server the Message was sent to
	// Signature: The signature of the Message that failed to send
	// Error: string describing the error
	SendMessageToGroupError = Type("SendMessageToGroupError")

	SendMessageToPeer  = Type("SendMessageToPeer")
	NewMessageFromPeer = Type("NewMessageFromPeer")

	// Peer acknowledges a previously sent message
	// attributes
	// EventID: The original event id that the peer is responding too.
	// RemotePeer: The peer associated with the acknowledgement
	PeerAcknowledgement = Type("PeerAcknowledgement")

	// attributes:
	// RemotePeer: [eg "chpr7qm6op5vfcg2pi4vllco3h6aa7exexc4rqwnlupqhoogx2zgd6qd"]
	// Error: string describing the error
	SendMessageToPeerError = Type("SendMessageToPeerError")

	// a peer contact has been added
	// attributes:
	// RemotePeer [eg ""]
	PeerCreated = Type("PeerCreated")

	// a group has been successfully added or newly created
	// attributes:
	// Data [serialized *model.Group]
	GroupCreated = Type("GroupCreated")

	// RemotePeer
	DeleteContact = Type("DeleteContact")

	// GroupID
	DeleteGroup = Type("DeleteGroup")

	// change the .Name attribute of a profile (careful - this is not a custom attribute. it is used in the underlying protocol during handshakes!)
	// attributes:
	// ProfileName [eg "erinn"]
	SetProfileName = Type("SetProfileName")

	// request to store a profile-wide attribute (good for e.g. per-profile settings like theme prefs)
	// attributes:
	// Key [eg "fontcolor"]
	// Data [eg "red"]
	SetAttribute = Type("SetAttribute")

	// request to store a per-contact attribute (e.g. display names for a peer)
	// attributes:
	// RemotePeer [eg ""]
	// Key [eg "nick"]
	// Data [eg "erinn"]
	SetPeerAttribute = Type("SetPeerAttribute")

	// request to store a per-cwtch-group attribute (e.g. display name for a group)
	// attributes:
	// GroupID [eg ""]
	// Key [eg "nick"]
	// Data [eg "open privacy board"]
	SetGroupAttribute = Type("SetGroupAttribute")

	// RemotePeer
	// ConnectionState
	PeerStateChange = Type("PeerStateChange")

	// GroupServer
	// ConnectionState
	ServerStateChange = Type("ServerStateChange")

	// ProfileName, Password
	CreatePeer = Type("CreatePeer")

	// service -> client: Identity(localId), Password, [Status(new/default=blank || from reload='running')]
	// app -> Identity(onion)
	NewPeer = Type("NewPeer")

	// Identity(onion), Data(pluginID)
	AddPeerPlugin = Type("AddPeerPlugin")

	// Password
	LoadProfiles = Type("LoadProfiles")

	// Client has reloaded, triggers NewPeer s then ReloadDone
	ReloadClient = Type("ReloadClient")

	ReloadDone = Type("ReloadDone")

	// Identity - Ask service to resend all connection states
	ReloadPeer = Type("ReloadPeer")

	// Identity(onion)
	ShutdownPeer = Type("ShutdownPeer")

	Shutdown = Type("Shutdown")

	// Error(err)
	PeerError = Type("PeerError")

	// Error(err)
	AppError = Type("AppError")

	// Progress, Status
	ACNStatus = Type("ACNStatus")
)

Defining Common Event Types

View Source
const (
	RemotePeer        = Field("RemotePeer")
	Ciphertext        = Field("Ciphertext")
	Signature         = Field("Signature")
	PreviousSignature = Field("PreviousSignature")
	TimestampSent     = Field("TimestampSent")
	TimestampReceived = Field("TimestampReceived")

	Identity = Field("Identity")

	GroupID     = Field("GroupID")
	GroupServer = Field("GroupServer")
	GroupInvite = Field("GroupInvite")

	ProfileName = Field("ProfileName")
	Password    = Field("Password")

	ConnectionState = Field("ConnectionState")

	Key  = Field("Key")
	Data = Field("Data")

	Error = Field("Error")

	Progreess    = Field("Progress")
	Status       = Field("Status")
	EventID      = Field("EventID")
	EventContext = Field("EventContext")
)

Defining Common Field Types

View Source
const (
	ContextAck    = "im.cwtch.acknowledgement"
	ContextInvite = "im.cwtch.invite"
	ContextRaw    = "im.cwtch.raw"
)

Defining Protocol Contexts

View Source
const (
	AppErrLoaded0 = "Loaded 0 profiles"
)

Defining Common errors

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	EventType Type
	EventID   string
	Data      map[Field]string
}

Event is a structure which binds a given set of data to an Type

func NewEvent

func NewEvent(eventType Type, data map[Field]string) Event

NewEvent creates a new event object with a unique ID and the given type and data.

func NewEventList

func NewEventList(eventType Type, args ...interface{}) Event

NewEventList creates a new event object with a unique ID and the given type and data supplied in a list format and composed into a map of Type:string

type Field

type Field string

Field defines common event attributes

type IPCBridge

type IPCBridge interface {
	Read() (*IPCMessage, bool)
	Write(message *IPCMessage)
	Shutdown()
}

IPCBridge is an interface to a IPC construct used to communicate IPCMessages

type IPCMessage

type IPCMessage struct {
	Dest    string
	Message Event
}

IPCMessage is a wrapper for a regular eventMessage with a destination (onion|AppDest) so the other side of the bridge can route appropriately

type Manager

type Manager interface {
	Subscribe(Type, Queue)
	Publish(Event)
	PublishLocal(Event)
	Shutdown()
}

Manager is an interface for an event bus

func IPCEventManagerFrom

func IPCEventManagerFrom(bridge IPCBridge, onion string, manager Manager) Manager

IPCEventManagerFrom returns an IPCEventManger from the supplied manager and IPCBridge

func NewEventManager

func NewEventManager() Manager

NewEventManager returns an initialized EventManager

func NewIPCEventManager

func NewIPCEventManager(bridge IPCBridge, onion string) Manager

NewIPCEventManager returns an EvenetManager that also pipes events over and supplied IPCBridge

type Queue

type Queue interface {
	InChan() chan<- Event
	OutChan() <-chan Event
	Next() *Event
	Shutdown()
	Len() int
}

Queue is a wrapper around a channel for handling Events in a consistent way across subsystems. The expectation is that each subsystem in Cwtch will manage a given an event.Queue fed from the event.Manager.

func NewQueue

func NewQueue() Queue

NewQueue initializes an event.Queue

func NewSimpleQueue

func NewSimpleQueue(buffer int) Queue

NewSimpleQueue initializes an event.Queue of the given buffer size.

type Type

type Type string

Type captures the definition of many common Cwtch application events

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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