user

package
v0.0.0-...-5c9eeab Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2019 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatroomUser

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

ChatroomUser implementation of User interface

func NewChatroomUser

func NewChatroomUser() *ChatroomUser

NewChatroomUser create a new chatroom user

func (*ChatroomUser) CreateUser

func (user *ChatroomUser) CreateUser() (string, error)

CreateUser creates a new user return a private key and a multi address

func (*ChatroomUser) FriendUser

func (user *ChatroomUser) FriendUser(name string, p2pAddr multiaddr.Multiaddr) error

FriendUser add a user to its peerstore for future use

func (*ChatroomUser) GetJoinedSpace

func (user *ChatroomUser) GetJoinedSpace() ([]string, error)

GetJoinedSpace returns all joined chatspace

func (*ChatroomUser) GetMyAddr

func (user *ChatroomUser) GetMyAddr() ([]multiaddr.Multiaddr, error)

GetMyAddr give back the addrinfo of the user

func (*ChatroomUser) GetMyID

func (user *ChatroomUser) GetMyID() (string, error)

GetMyID give back peerId of user

func (*ChatroomUser) JoinSpace

func (user *ChatroomUser) JoinSpace(spaceName string) error

JoinSpace join a new chatspace

func (*ChatroomUser) LeaveSpace

func (user *ChatroomUser) LeaveSpace(spaceName string) error

LeaveSpace leave a joined chatspace

func (*ChatroomUser) Login

func (user *ChatroomUser) Login(key string, port int) error

Login use given private key to construct the host for user

func (*ChatroomUser) Logout

func (user *ChatroomUser) Logout() error

Logout terminate the host

func (*ChatroomUser) PublishMessage

func (user *ChatroomUser) PublishMessage(spaceName string, data []byte) error

PublishMessage publishes message to chatspace

func (*ChatroomUser) ReceiveMessage

func (user *ChatroomUser) ReceiveMessage(spaceName string) ([]byte, error)

ReceiveMessage receive message from chatspace

func (*ChatroomUser) SetProfile

func (user *ChatroomUser) SetProfile(field string, data string)

SetProfile set a field in the profile with given parameter

func (*ChatroomUser) UnfriendUser

func (user *ChatroomUser) UnfriendUser(name string) error

UnfriendUser a user from connection using friend name

type P2PUser

type P2PUser interface {
	// create peer identity
	CreateUser() (string, error)

	// GetMyAddr get my p2p address info
	GetMyAddr() ([]multiaddr.Multiaddr, error)

	// GetMyAddr get my p2p id info
	GetMyID() (string, error)

	// login created peer identity
	Login(key string, port int) error

	// logout current peer identity
	Logout() error

	// friend other user
	FriendUser(name string, p2pAddr multiaddr.Multiaddr) error

	// unfriend other user
	UnfriendUser(id string) error

	// Join a new space
	JoinSpace(spaceName string) error

	// leave a joined space
	LeaveSpace(spaceName string) error

	// get currently joined spaces
	GetJoinedSpace() ([]string, error)
}

P2PUser interface

type Profile

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

Profile is a basic profile struct.

func (Profile) ChangeProfile

func (profile Profile) ChangeProfile(field string, data string)

ChangeProfile changes user's profile

Jump to

Keyboard shortcuts

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