Documentation
¶
Overview ¶
Package socket handles communication with a player using a websocket connection
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { // Debug is a flag that causes the socket to log the types non-ping/pong messages that are read/written Debug bool // Log is used to log errors and other information Log *log.Logger // TimeFunc is a function which should supply the current time since the unix epoch. // Used to set ping/pong deadlines TimeFunc func() int64 // PongPeriod is the amount of time that between messages that can bass before the connection is invalid PongPeriod time.Duration // PingPeriod is the amount of time between sending ping messages to the connection to keep it active // Should be less than pongPeriod PingPeriod time.Duration // IdlePeroid is the amount of time that can pass between handling messages that are not pings before the connection is idle and will be disconnected IdlePeriod time.Duration // HTTPPingPeriod is the amount of time between sending requests for the connection to send a http ping on a different socket // Heroku servers shut down if 30 minutes passess between HTTP requests HTTPPingPeriod time.Duration }
Config contains commonly shared Socket properties
type Socket ¶
type Socket struct {
// contains filtered or unexported fields
}
Socket reads and writes messages to the browsers
func (*Socket) Run ¶
func (s *Socket) Run(ctx context.Context, removeSocketFunc context.CancelFunc, readMessages chan<- game.Message, writeMessages <-chan game.Message)
Run writes Socket messages to the messages channel and reads incoming messages on separate goroutines The Socket runs until the connection fails for an unexpected reason or a message is received on the "done"< channel. Messages the socket receives are sent to the provided channel. Messages the socket sends are consumed from the returned channel.
Click to show internal directories.
Click to hide internal directories.