diff --git a/socketserver/server/handlecore.go b/socketserver/server/handlecore.go index bba45d62..882d6f76 100644 --- a/socketserver/server/handlecore.go +++ b/socketserver/server/handlecore.go @@ -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 diff --git a/socketserver/server/subscriptions.go b/socketserver/server/subscriptions.go index 136fa603..7486876b 100644 --- a/socketserver/server/subscriptions.go +++ b/socketserver/server/subscriptions.go @@ -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 diff --git a/socketserver/server/types.go b/socketserver/server/types.go index e5b464d9..24482261 100644 --- a/socketserver/server/types.go +++ b/socketserver/server/types.go @@ -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)