Documentation
¶
Index ¶
Constants ¶
const ( MaxPayloadSize = cookie.MaxPayloadSize DefaultRequestTimeout = 10 * time.Second )
Variables ¶
var ( ErrUnsupportedClientProtocol = errors.New("player version must be at least 1.20.5 to use cookies") ErrUnsupportedState = fmt.Errorf("cookie can only be stored in %s or %s state", states.ConfigState, states.PlayState) )
Functions ¶
func Clear ¶
Clear clears a stored cookie from the player's client. This is a helper function that stores a cookie with an empty payload.
If the player's protocol is below 1.20.5, ErrUnsupportedClientProtocol is returned. If the player's state is not states.ConfigState or states.PlayState, ErrUnsupportedState is returned.
func RequestAndForget ¶
RequestAndForget works like Request but does not wait for a response.
The cookie response event will still be fired by Gate and can be listened to in the event manager.
Types ¶
type Client ¶
type Client interface {
proto.PacketWriter
Context() context.Context
}
Client is a player that can store and send stored cookies.
type Cookie ¶
Cookie is cookie that can be sent and received from clients.
Use Store to save a cookie on the client. When the cookie is modified, Store must be called again to save the changes.
The maximum size of a cookie is 5 kiB.
func Request ¶
Request requests a stored cookie from the player's client by a given key. This is a blocking operation and the context should be used to timeout the request. The DefaultRequestTimeout always applies as a safety net.
The event manager is used to listen for the cookie response event fired by Gate. Use proxy.Event() to get the proxy's event manager.
Request only subscribes to the cookie response event only until Request returns.