core

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2023 License: GPL-3.0 Imports: 35 Imported by: 1

README

core

Bee messenger core

Documentation

Index

Constants

View Source
const (
	JOINED = "joined"
)
View Source
const Timeout = 60 * 5

Variables

View Source
var BootstrapNodes = []string{
	"/ip4/194.5.178.130/tcp/4002/p2p/12D3KooWK5ok6gr6L5SVuaAtme3HfUWW4YYm4AAsqUYfZeonKM1C",
	"/ip6/2a01:4f8:160:33c5:250:56ff:fe94:dedc/tcp/4002/p2p/12D3KooWK5ok6gr6L5SVuaAtme3HfUWW4YYm4AAsqUYfZeonKM1C",
	"/ip4/194.5.178.130/udp/4002/quic/p2p/12D3KooWK5ok6gr6L5SVuaAtme3HfUWW4YYm4AAsqUYfZeonKM1C",
	"/ip6/2a01:4f8:160:33c5:250:56ff:fe94:dedc/udp/4002/quic/p2p/12D3KooWK5ok6gr6L5SVuaAtme3HfUWW4YYm4AAsqUYfZeonKM1C",
	"/ip4/194.5.178.130/udp/4002/quic-v1/p2p/12D3KooWK5ok6gr6L5SVuaAtme3HfUWW4YYm4AAsqUYfZeonKM1C",
	"/ip6/2a01:4f8:160:33c5:250:56ff:fe94:dedc/udp/4002/quic-v1/p2p/12D3KooWK5ok6gr6L5SVuaAtme3HfUWW4YYm4AAsqUYfZeonKM1C",
}
View Source
var StaticRelays = []string{
	"/ip6/2a01:4f8:160:33c5:250:56ff:fe94:dedc/udp/4001/quic/p2p/12D3KooWBFpA7pCMBySBqtduBVkakVQ3bmmaeagB83WHoruBN9s9",
	"/ip4/194.5.178.130/tcp/4001/p2p/12D3KooWBFpA7pCMBySBqtduBVkakVQ3bmmaeagB83WHoruBN9s9",
	"/ip6/2a01:4f8:160:33c5:250:56ff:fe94:dedc/tcp/4001/p2p/12D3KooWBFpA7pCMBySBqtduBVkakVQ3bmmaeagB83WHoruBN9s9",
	"/ip4/194.5.178.130/udp/4001/quic/p2p/12D3KooWBFpA7pCMBySBqtduBVkakVQ3bmmaeagB83WHoruBN9s9",
}

Functions

func ParseBootstrapPeers

func ParseBootstrapPeers(addrs []string) ([]peer.AddrInfo, error)

Types

type Builder added in v0.2.0

type Builder interface {
	Create(opt Option) (host.Host, error)
}

type Bus added in v0.2.0

type Bus = event.Bus

type Chat added in v0.2.0

type Chat struct {
	Identity IdentityAPI
	// contains filtered or unexported fields
}

func (*Chat) ChatInfo added in v0.2.0

func (c *Chat) ChatInfo(id entity.ID) (entity.ChatInfo, error)

func (*Chat) ChatInfos added in v0.2.0

func (c *Chat) ChatInfos(skip int, limit int) ([]entity.ChatInfo, error)

func (*Chat) Find added in v0.2.0

func (c *Chat) Find(opt SearchChatOpt) ([]entity.ChatInfo, error)

func (*Chat) Invite added in v0.3.0

func (c *Chat) Invite(chatID entity.ID, cons []entity.Contact) error

func (*Chat) Join added in v0.3.0

func (c *Chat) Join(ci entity.ChatInfo) error

func (*Chat) Message added in v0.2.0

func (c *Chat) Message(ID entity.ID) (entity.Message, error)

func (*Chat) Messages added in v0.2.0

func (c *Chat) Messages(chatID entity.ID, skip int, limit int) ([]entity.Message, error)

func (*Chat) New added in v0.2.0

func (c *Chat) New(opt NewChatOpt) (entity.ChatInfo, error)

func (*Chat) Seen added in v0.2.0

func (c *Chat) Seen(chatID entity.ID) error

func (*Chat) Send added in v0.2.0

func (c *Chat) Send(chatID entity.ID, content string) (*entity.Message, error)

type ChatAPI added in v0.2.0

type ChatAPI interface {
	ChatInfo(id entity.ID) (entity.ChatInfo, error)
	ChatInfos(skip int, limit int) ([]entity.ChatInfo, error)
	Join(entity.ChatInfo) error
	Find(opt SearchChatOpt) ([]entity.ChatInfo, error)
	New(opt NewChatOpt) (entity.ChatInfo, error)
	Send(chatID entity.ID, content string) (*entity.Message, error)
	Seen(chatID entity.ID) error
	Message(ID entity.ID) (entity.Message, error)
	Messages(chatID entity.ID, skip int, limit int) ([]entity.Message, error)
	Invite(chID entity.ID, cons []entity.Contact) error
	// contains filtered or unexported methods
}

provide api to use chat

func NewChatAPI added in v0.2.0

func NewChatAPI(store *st.Store, b ContactBookAPI, p DirectService, g PubSubService, i IdentityAPI) ChatAPI

type ChatRepo added in v0.2.0

type ChatRepo = rp.IRepo[entity.ChatInfo]

type ChatRequest added in v0.3.0

type ChatRequest struct {
	ID      entity.ID
	Name    string
	Members []entity.Contact
	Type    entity.ChatType
	Admins  []entity.Contact
}

type ChatRoom added in v0.3.0

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

ChatRoom represents a subscription to a single PubSub topic. Messages can be published to the topic with ChatRoom.Publish, and received messages are pushed to the Messages channel.

type Connector added in v0.1.0

type Connector interface {
	Need(proc string, p peer.AddrInfo)
	Done(proc string, p peer.ID)
}

func NewConnector added in v0.1.0

func NewConnector(h host.Host) Connector

type ContactBook added in v0.2.0

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

func (*ContactBook) Get added in v0.2.0

func (c *ContactBook) Get(id entity.ID) (entity.Contact, error)

func (*ContactBook) List added in v0.2.0

func (c *ContactBook) List(skip int, limit int) ([]entity.Contact, error)

func (*ContactBook) Put added in v0.2.0

func (c *ContactBook) Put(con entity.Contact) error

type ContactBookAPI added in v0.2.0

type ContactBookAPI interface {
	// return list of contact
	List(skip int, limit int) ([]entity.Contact, error)
	// return a contact by id
	Get(id entity.ID) (entity.Contact, error)
	// create or update contact
	Put(c entity.Contact) error
}

provide api for managing contacts

func NewContactBook added in v0.2.0

func NewContactBook(store *st.Store) ContactBookAPI

type Data added in v0.1.0

type Data map[peer.ID][]DataItem

type DataItem added in v0.3.0

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

type DefaultRoutedHost

type DefaultRoutedHost struct {
}

func (DefaultRoutedHost) Create

func (b DefaultRoutedHost) Create(opt Option) (host.Host, error)

type DirectMessaging added in v0.3.0

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

func (*DirectMessaging) Send added in v0.3.0

func (c *DirectMessaging) Send(nvlop *entity.Envelop)

func (*DirectMessaging) Stop added in v0.3.0

func (c *DirectMessaging) Stop()

type DirectService added in v0.3.0

type DirectService interface {
	Send(nvlop *entity.Envelop)
	Stop()
}

func NewDirectMessaging added in v0.3.0

func NewDirectMessaging(h host.Host, ebus Bus, connector Connector, input chan *entity.Envelop) DirectService

NewDirectMessaging creates a Direct messaging service

type Emitter added in v0.3.0

type Emitter = event.Emitter

type GPService added in v0.3.0

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

func (*GPService) Join added in v0.3.0

func (s *GPService) Join(ChatID entity.ID, admins []entity.Contact)

func (*GPService) JoinChatRoom added in v0.3.0

func (s *GPService) JoinChatRoom(chatID string) error

JoinChatRoom tries to subscribe to the PubSub topic for the room name, returning a ChatRoom on success.

func (*GPService) OnlinePeers added in v0.3.0

func (s *GPService) OnlinePeers(chatID string) []peer.ID

func (*GPService) Send added in v0.3.0

func (s *GPService) Send(n entity.PubSubEnvelop)

func (*GPService) Stop added in v0.3.0

func (s *GPService) Stop()

type Identity added in v0.2.0

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

func (*Identity) Get added in v0.2.0

func (i *Identity) Get() (entity.Identity, error)

func (*Identity) IsLogin added in v0.2.0

func (i *Identity) IsLogin() bool

func (*Identity) PeerID added in v0.3.0

func (i *Identity) PeerID() (peer.ID, error)

func (*Identity) SignUp added in v0.2.0

func (i *Identity) SignUp(name string) (*entity.Identity, error)

type IdentityAPI added in v0.2.0

type IdentityAPI interface {
	IsLogin() bool
	SignUp(name string) (*entity.Identity, error)
	Get() (entity.Identity, error)
	PeerID() (peer.ID, error)
}

provide api for managing identity

func NewIdentityAPI added in v0.2.0

func NewIdentityAPI(store *st.Store) IdentityAPI

type IdentityRepo added in v0.2.0

type IdentityRepo = rp.IRepo[entity.Identity]

type Info added in v0.1.0

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

type MessageRepo added in v0.2.0

type MessageRepo = rp.IRepo[entity.Message]

type Messenger

type Messenger struct {
	Host host.Host
	// contains filtered or unexported fields
}

func (*Messenger) ChatAPI added in v0.2.0

func (m *Messenger) ChatAPI() ChatAPI

func (*Messenger) ContactBookAPI added in v0.2.0

func (m *Messenger) ContactBookAPI() ContactBookAPI

func (*Messenger) EventBus added in v0.1.0

func (m *Messenger) EventBus() Bus

func (*Messenger) IdentityAPI added in v0.2.0

func (m *Messenger) IdentityAPI() IdentityAPI

func (*Messenger) Start

func (m *Messenger) Start()

func (*Messenger) Stop added in v0.1.0

func (m *Messenger) Stop()

type MessengerAPI added in v0.2.0

type MessengerAPI interface {
	ContactBookAPI() ContactBookAPI
	ChatAPI() ChatAPI
	IdentityAPI() IdentityAPI
	EventBus() Bus
	Start()
	Stop()
}

func NewMessengerAPI added in v0.2.0

func NewMessengerAPI(path string, opt Option, hb Builder) MessengerAPI

type NewChatOpt added in v0.3.0

type NewChatOpt struct {
	Name    string
	Members []entity.Contact
	Type    entity.ChatType
}

func NewPrivateChat added in v0.3.0

func NewPrivateChat(contact entity.Contact) NewChatOpt

type Option

type Option struct {
	LpOpt []libp2p.Option
	ID    peer.ID
}

func DefaultOption

func DefaultOption() Option

func (*Option) SetIdentity

func (opt *Option) SetIdentity(identity *entity.Identity) error

type PeerSet added in v0.1.0

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

func NewPeerSet added in v0.1.0

func NewPeerSet() *PeerSet

func (*PeerSet) Add added in v0.1.0

func (p *PeerSet) Add(proc string, pa peer.AddrInfo)

func (*PeerSet) Done added in v0.1.0

func (p *PeerSet) Done(id peer.ID)

func (*PeerSet) Empty added in v0.1.0

func (p *PeerSet) Empty() bool

func (*PeerSet) Failed added in v0.1.0

func (p *PeerSet) Failed(id peer.ID)

func (*PeerSet) Force added in v0.1.0

func (p *PeerSet) Force(id peer.ID)

func (*PeerSet) Remove added in v0.1.0

func (p *PeerSet) Remove(proc string, pid peer.ID)

func (*PeerSet) Turn added in v0.1.0

func (p *PeerSet) Turn(t time.Time) []peer.AddrInfo

type PubSubService added in v0.3.0

type PubSubService interface {
	Send(entity.PubSubEnvelop)
	Stop()
	Join(chatId entity.ID, members []entity.Contact)
}

func NewGPService added in v0.3.0

func NewGPService(ctx context.Context, h host.Host, identity IdentityAPI, b Bus, ch chan string, c Connector) PubSubService

type SearchChatOpt added in v0.3.0

type SearchChatOpt struct {
	Name    string
	Members []entity.ID
	Type    entity.ChatType
}

func WithPrivateChatContact added in v0.3.0

func WithPrivateChatContact(contactID entity.ID) SearchChatOpt

Directories

Path Synopsis
protocol

Jump to

Keyboard shortcuts

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