1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-06-27 21:05:53 +00:00

Make client.messageChannel unexported

This commit is contained in:
Kane York 2017-10-27 13:14:29 -07:00
parent a900d1521e
commit 85a0fb7b79
3 changed files with 12 additions and 10 deletions

View file

@ -366,7 +366,7 @@ func RunSocketConnection(conn *websocket.Conn) {
stoppedChan := make(chan struct{})
var client ClientInfo
client.MessageChannel = _serverMessageChan
client.messageChannel = _serverMessageChan
client.RemoteAddr = conn.RemoteAddr()
client.MsgChannelIsDone = stoppedChan

View file

@ -18,9 +18,11 @@ var ChatSubscriptionLock sync.RWMutex
var GlobalSubscriptionInfo []*ClientInfo
var GlobalSubscriptionLock sync.RWMutex
// Send a message to the client.
// Drops if buffer is full.
func (client *ClientInfo) Send(msg ClientMessage) bool {
select {
case client.MessageChannel <- msg:
case client.messageChannel <- msg:
return true
case <-client.MsgChannelIsDone:
return false

View file

@ -94,12 +94,6 @@ type AuthInfo struct {
UsernameValidated bool
}
type ClientVersion struct {
Major int
Minor int
Revision int
}
type ClientInfo struct {
// The client ID.
// This must be written once by the owning goroutine before the struct is passed off to any other goroutines.
@ -134,15 +128,21 @@ type ClientInfo struct {
ReadyComplete bool
// Server-initiated messages should be sent via the Send() method.
MessageChannel chan<- ClientMessage
messageChannel chan<- ClientMessage
// Closed when the client is shutting down.
MsgChannelIsDone <-chan struct{}
// Take out an Add() on this during a command if you need to use the MessageChannel later.
// Take out an Add() on this during a command if you need to call Send() later.
MsgChannelKeepalive sync.WaitGroup
}
type ClientVersion struct {
Major int
Minor int
Revision int
}
func VersionFromString(v string) ClientVersion {
var cv ClientVersion
fmt.Sscanf(v, "ffz_%d.%d.%d", &cv.Major, &cv.Minor, &cv.Revision)