groupChat

package
v4.7.2 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: BSD-2-Clause, BSD-2-Clause Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const MaxInitMessageSize = 256

MaxInitMessageSize is the maximum allowable length of the initial message sent in a group request.

Variables

View Source
var File_gcMessages_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type GroupChat

type GroupChat interface {
	// MakeGroup sends GroupChat requests to all members over an authenticated
	// channel. The leader of a GroupChat must have an authenticated channel
	// with each member of the GroupChat to add them to the GroupChat. It blocks
	// until all the GroupChat requests are sent. Returns the new group and the
	// round IDs the requests were sent on. Returns an error if at least one
	// request to a member fails to send. Also returns the status of the sent
	// requests.
	MakeGroup(membership []*id.ID, name, message []byte) (gs.Group, []id.Round,
		RequestStatus, error)

	// ResendRequest allows a GroupChat request to be sent again. It returns
	// the rounds that the requests were sent on and the status of the send.
	ResendRequest(groupID *id.ID) ([]id.Round, RequestStatus, error)

	// JoinGroup allows a user to accept a GroupChat request and stores the
	// GroupChat as active to allow receiving and sending of messages from/to
	// the GroupChat. A user can only join a GroupChat once.
	JoinGroup(g gs.Group) error

	// LeaveGroup removes a group from a list of groups the user is a part of.
	LeaveGroup(groupID *id.ID) error

	// Send sends a message to all GroupChat members using Cmix.SendManyCMIX.
	// The send fails if the message is too long. Returns the ID of the round
	// sent on and the timestamp of the message send.
	Send(groupID *id.ID, tag string, message []byte) (
		rounds.Round, time.Time, group.MessageID, error)

	// GetGroups returns a list of all registered GroupChat IDs.
	GetGroups() []*id.ID

	// GetGroup returns the group with the matching ID or returns false if none
	// exist.
	GetGroup(groupID *id.ID) (gs.Group, bool)

	// NumGroups returns the number of groups the user is a part of.
	NumGroups() int

	// AddService adds a service for all group chat partners of the given tag,
	// which will call back on the given processor.
	AddService(tag string, p Processor) error

	// RemoveService removes all services for the given tag.
	RemoveService(tag string) error
}

GroupChat is used to send and receive cMix messages to/from multiple users.

func NewManager

func NewManager(user groupE2e,
	requestFunc RequestCallback, receiveFunc Processor) (GroupChat, error)

NewManager creates a new group chat manager

type MessageReceive

type MessageReceive struct {
	GroupID   *id.ID
	ID        group.MessageID
	Payload   []byte
	SenderID  *id.ID
	Timestamp time.Time
}

MessageReceive contains the GroupChat message and associated data that a user receives when getting a group message.

func (MessageReceive) String

func (mr MessageReceive) String() string

String returns the MessageReceive as readable text. This functions adheres to the fmt.Stringer interface.

type Processor

type Processor interface {
	// Process decrypts and hands off the message to its internal down stream
	// message processing system.
	Process(decryptedMsg MessageReceive, msg format.Message, _ []string, _ []byte,
		receptionID receptionID.EphemeralIdentity, round rounds.Round)

	// Stringer interface for debugging.
	fmt.Stringer
}

Processor manages the handling of received group chat messages.

type ReceiveCallback

type ReceiveCallback func(msg MessageReceive)

ReceiveCallback is called when a GroupChat message is received.

type Request

type Request struct {
	Name        []byte `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	IdPreimage  []byte `protobuf:"bytes,2,opt,name=idPreimage,proto3" json:"idPreimage,omitempty"`
	KeyPreimage []byte `protobuf:"bytes,3,opt,name=keyPreimage,proto3" json:"keyPreimage,omitempty"`
	Members     []byte `protobuf:"bytes,4,opt,name=members,proto3" json:"members,omitempty"`
	Message     []byte `protobuf:"bytes,5,opt,name=message,proto3" json:"message,omitempty"`
	Created     int64  `protobuf:"varint,6,opt,name=created,proto3" json:"created,omitempty"`
	// contains filtered or unexported fields
}

Request to join the group sent from leader to all members.

func (*Request) Descriptor deprecated

func (*Request) Descriptor() ([]byte, []int)

Deprecated: Use Request.ProtoReflect.Descriptor instead.

func (*Request) GetCreated

func (x *Request) GetCreated() int64

func (*Request) GetIdPreimage

func (x *Request) GetIdPreimage() []byte

func (*Request) GetKeyPreimage

func (x *Request) GetKeyPreimage() []byte

func (*Request) GetMembers

func (x *Request) GetMembers() []byte

func (*Request) GetMessage

func (x *Request) GetMessage() []byte

func (*Request) GetName

func (x *Request) GetName() []byte

func (*Request) ProtoMessage

func (*Request) ProtoMessage()

func (*Request) ProtoReflect

func (x *Request) ProtoReflect() protoreflect.Message

func (*Request) Reset

func (x *Request) Reset()

func (*Request) String

func (x *Request) String() string

type RequestCallback

type RequestCallback func(g gs.Group)

RequestCallback is called when a GroupChat request is received.

type RequestStatus

type RequestStatus int

RequestStatus signals the status of the group requests on group creation.

const (
	NotSent     RequestStatus = iota // Error occurred before sending requests
	AllFail                          // Sending of all requests failed
	PartialSent                      // Sending of some request failed
	AllSent                          // Sending of all request succeeded
)

func (RequestStatus) Message

func (rs RequestStatus) Message() string

Message prints a full description of the status code.

func (RequestStatus) String

func (rs RequestStatus) String() string

String prints the description of the status code. This functions satisfies the fmt.Stringer interface.

type Wrapper

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

Wrapper handles the sending and receiving of group chat using E2E messages to inform the recipient of incoming group chat messages.

func NewWrapper

func NewWrapper(manager GroupChat) *Wrapper

NewWrapper constructs a wrapper around the GroupChat interface.

func (*Wrapper) GetGroup

func (w *Wrapper) GetGroup(groupID *id.ID) (gs.Group, bool)

GetGroup calls GroupChat.GetGroup.

func (*Wrapper) GetGroups

func (w *Wrapper) GetGroups() []*id.ID

GetGroups calls GroupChat.GetGroups.

func (*Wrapper) JoinGroup

func (w *Wrapper) JoinGroup(grp gs.Group) error

JoinGroup calls GroupChat.JoinGroup.

func (*Wrapper) LeaveGroup

func (w *Wrapper) LeaveGroup(groupID *id.ID) error

LeaveGroup calls GroupChat.LeaveGroup.

func (*Wrapper) MakeGroup

func (w *Wrapper) MakeGroup(membership []*id.ID, name, message []byte) (
	gs.Group, []id.Round, RequestStatus, error)

MakeGroup calls GroupChat.MakeGroup.

func (*Wrapper) NumGroups

func (w *Wrapper) NumGroups() int

NumGroups calls GroupChat.NumGroups.

func (*Wrapper) ResendRequest

func (w *Wrapper) ResendRequest(groupID *id.ID) ([]id.Round, RequestStatus, error)

ResendRequest calls GroupChat.ResendRequest.

func (*Wrapper) Send

func (w *Wrapper) Send(groupID *id.ID, message []byte, tag string) (
	rounds.Round, time.Time, group.MessageID, error)

Send calls GroupChat.Send.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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