Documentation
¶
Index ¶
- type ChatroomUser
- func (user *ChatroomUser) CreateUser() (string, error)
- func (user *ChatroomUser) FriendUser(name string, p2pAddr multiaddr.Multiaddr) error
- func (user *ChatroomUser) GetJoinedSpace() ([]string, error)
- func (user *ChatroomUser) GetMyAddr() ([]multiaddr.Multiaddr, error)
- func (user *ChatroomUser) GetMyID() (string, error)
- func (user *ChatroomUser) JoinSpace(spaceName string) error
- func (user *ChatroomUser) LeaveSpace(spaceName string) error
- func (user *ChatroomUser) Login(key string, port int) error
- func (user *ChatroomUser) Logout() error
- func (user *ChatroomUser) PublishMessage(spaceName string, data []byte) error
- func (user *ChatroomUser) ReceiveMessage(spaceName string) ([]byte, error)
- func (user *ChatroomUser) SetProfile(field string, data string)
- func (user *ChatroomUser) UnfriendUser(name string) error
- type P2PUser
- type Profile
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) 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