Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatRoom ¶
type ChatRoom struct { // Represents the P2P Host for the ChatRoom Host *P2P // Represents the channel of incoming messages Inbound chan chatmessage // Represents the channel of outgoing messages Outbound chan string // Represents the channel of chat log messages Logs chan chatlog // Represents the name of the chat room RoomName string // Represent the name of the user in the chat room UserName string // contains filtered or unexported fields }
A structure that represents a PubSub Chat Room
func JoinChatRoom ¶
A constructor function that generates and returns a new ChatRoom for a given P2PHost, username and roomname
func (*ChatRoom) Exit ¶
func (cr *ChatRoom) Exit()
A method of ChatRoom that updates the chat room by subscribing to the new topic
func (*ChatRoom) PeerList ¶
A method of ChatRoom that returns a list of all peer IDs connected to it
func (*ChatRoom) PubLoop ¶
func (cr *ChatRoom) PubLoop()
A method of ChatRoom that publishes a chatmessage to the PubSub topic until the pubsub context closes
func (*ChatRoom) SubLoop ¶
func (cr *ChatRoom) SubLoop()
A method of ChatRoom that continously reads from the subscription until either the subscription or pubsub context closes. The recieved message is parsed sent into the inbound channel
func (*ChatRoom) UpdateUser ¶
A method of ChatRoom that updates the chat user name
type P2P ¶
type P2P struct { // Represents the host context layer Ctx context.Context // Represents the libp2p host Host host.Host // Represents the DHT routing table KadDHT *dht.IpfsDHT // Represents the peer discovery service Discovery *discovery.RoutingDiscovery // Represents the PubSub Handler PubSub *pubsub.PubSub }
A structure that represents a P2P Host
func NewP2P ¶
func NewP2P() *P2P
A constructor function that generates and returns a P2P object.
Constructs a libp2p host with TLS encrypted secure transportation that works over a TCP transport connection using a Yamux Stream Multiplexer and uses UPnP for the NAT traversal.
A Kademlia DHT is then bootstrapped on this host using the default peers offered by libp2p and a Peer Discovery service is created from this Kademlia DHT. The PubSub handler is then created on the host using the peer discovery service created prior.
func (*P2P) AdvertiseConnect ¶
func (p2p *P2P) AdvertiseConnect()
A method of P2P to connect to service peers. This method uses the Advertise() functionality of the Peer Discovery Service to advertise the service and then disovers all peers advertising the same. The peer discovery is handled by a go-routine that will read from a channel of peer address information until the peer channel closes
func (*P2P) AnnounceConnect ¶
func (p2p *P2P) AnnounceConnect()
A method of P2P to connect to service peers. This method uses the Provide() functionality of the Kademlia DHT directly to announce the ability to provide the service and then disovers all peers that provide the same. The peer discovery is handled by a go-routine that will read from a channel of peer address information until the peer channel closes
type UI ¶
type UI struct { // Represents the ChatRoom (embedded) *ChatRoom // Represents the tview application TerminalApp *tview.Application // Represents the user message input queue MsgInputs chan string // Represents the user command input queue CmdInputs chan uicommand // contains filtered or unexported fields }
A structure that represents the ChatRoom UI