refactor: Move extraneous User interfaces from chat to host

This commit is contained in:
Andrey Petrov committed 2017-04-28 11:43:15 -04:00
1 parent 7f2b8e4689
commit cd5686e20e
3 files changed
+18 -14

No files matched your search

+1 -9
View File
@@ -1,8 +1,6 @@
package chat
import (
"time"
"github.com/shazow/ssh-chat/chat/message"
"github.com/shazow/ssh-chat/set"
)
@@ -16,16 +14,10 @@ type roomMember struct {
type Member interface {
message.Author
SetName(string)
Config() message.UserConfig
SetConfig(message.UserConfig)
Send(message.Message) error
Joined() time.Time
ReplyTo() message.Author
SetReplyTo(message.Author)
Prompt() string
SetHighlight(string) error
SetName(string)
}
+14 -2
View File
@@ -2,13 +2,15 @@ package sshchat
import (
"sync"
"time"
"github.com/shazow/ssh-chat/chat"
"github.com/shazow/ssh-chat/chat/message"
"github.com/shazow/ssh-chat/sshd"
)
type client struct {
chat.Member
UserMember
sync.Mutex
conns []sshd.Connection
}
@@ -25,9 +27,19 @@ func (cl *client) Close() error {
return nil
}
type User interface {
type UserMember interface {
chat.Member
Joined() time.Time
Prompt() string
ReplyTo() message.Author
SetHighlight(string) error
SetReplyTo(message.Author)
}
type User interface {
UserMember
Connections() []sshd.Connection
Close() error
}
+3 -3
View File
@@ -77,8 +77,8 @@ func (h *Host) Connect(term *sshd.Terminal) {
requestedName := term.Conn.Name()
screen := message.BufferedScreen(requestedName, term)
user := &client{
Member: screen,
conns: []sshd.Connection{term.Conn},
UserMember: screen,
conns: []sshd.Connection{term.Conn},
}
h.mu.Lock()
@@ -316,7 +316,7 @@ func (h *Host) InitCommands(c *chat.Commands) {
return errors.New("must specify message")
}
target := msg.From().(chat.Member).ReplyTo()
target := msg.From().(UserMember).ReplyTo()
if target == nil {
return errors.New("no message to reply to")
}