Skip to content

Commit cd5686e

Browse files
committed
refactor: Move extraneous User interfaces from chat to host
1 parent 7f2b8e4 commit cd5686e

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

chat/member.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package chat
22

33
import (
4-
"time"
5-
64
"github.com/shazow/ssh-chat/chat/message"
75
"github.com/shazow/ssh-chat/set"
86
)
@@ -16,16 +14,10 @@ type roomMember struct {
1614
type Member interface {
1715
message.Author
1816

19-
SetName(string)
20-
2117
Config() message.UserConfig
2218
SetConfig(message.UserConfig)
2319

2420
Send(message.Message) error
2521

26-
Joined() time.Time
27-
ReplyTo() message.Author
28-
SetReplyTo(message.Author)
29-
Prompt() string
30-
SetHighlight(string) error
22+
SetName(string)
3123
}

client.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ package sshchat
22

33
import (
44
"sync"
5+
"time"
56

67
"github.com/shazow/ssh-chat/chat"
8+
"github.com/shazow/ssh-chat/chat/message"
79
"github.com/shazow/ssh-chat/sshd"
810
)
911

1012
type client struct {
11-
chat.Member
13+
UserMember
1214
sync.Mutex
1315
conns []sshd.Connection
1416
}
@@ -25,9 +27,19 @@ func (cl *client) Close() error {
2527
return nil
2628
}
2729

28-
type User interface {
30+
type UserMember interface {
2931
chat.Member
3032

33+
Joined() time.Time
34+
Prompt() string
35+
ReplyTo() message.Author
36+
SetHighlight(string) error
37+
SetReplyTo(message.Author)
38+
}
39+
40+
type User interface {
41+
UserMember
42+
3143
Connections() []sshd.Connection
3244
Close() error
3345
}

host.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ func (h *Host) Connect(term *sshd.Terminal) {
7777
requestedName := term.Conn.Name()
7878
screen := message.BufferedScreen(requestedName, term)
7979
user := &client{
80-
Member: screen,
81-
conns: []sshd.Connection{term.Conn},
80+
UserMember: screen,
81+
conns: []sshd.Connection{term.Conn},
8282
}
8383

8484
h.mu.Lock()
@@ -316,7 +316,7 @@ func (h *Host) InitCommands(c *chat.Commands) {
316316
return errors.New("must specify message")
317317
}
318318

319-
target := msg.From().(chat.Member).ReplyTo()
319+
target := msg.From().(UserMember).ReplyTo()
320320
if target == nil {
321321
return errors.New("no message to reply to")
322322
}

0 commit comments

Comments
 (0)