Documentation
¶
Overview ¶
Package cm implements Steam Connection Manager transport and sessions.
Index ¶
- Constants
- func EncodeFrame(frame Frame, limits FrameLimits) ([]byte, error)
- type Client
- func (c *Client) CallUnauthenticated(ctx context.Context, method string, body []byte) (Message, error)
- func (c *Client) Close() error
- func (c *Client) Connect(ctx context.Context, endpoint Endpoint) error
- func (c *Client) LogonAnonymous(ctx context.Context) (*Session, error)
- func (c *Client) LogonToken(ctx context.Context, details TokenLogonDetails) (*Session, error)
- type ClientOption
- type Directory
- type DirectoryError
- type DirectoryQuery
- type Endpoint
- type Frame
- type FrameLimits
- type HTTPError
- type Header
- type JobError
- type JobRequest
- type LogoffError
- type LogonError
- type Message
- type MissingEResultError
- type MultiLimits
- type Session
- type SessionState
- type TokenLogonDetails
- type WebSocketConn
- type WebSocketOption
Constants ¶
const ( EResultOK int32 = 1 EResultFail int32 = 2 EResultAccessDenied int32 = 15 )
Common Steam EResult values returned by CM operations.
const ( EMsgMulti uint32 = 1 EMsgClientHeartBeat uint32 = 703 EMsgClientLoggedOff uint32 = 757 EMsgClientLogOnResponse uint32 = 751 EMsgClientLogon uint32 = 5514 EMsgClientGMSServerQuery uint32 = 6403 EMsgGMSClientServerQueryResponse uint32 = 6404 EMsgServiceMethod uint32 = 146 EMsgServiceMethodResponse uint32 = 147 EMsgServiceMethodCallFromClient uint32 = 151 )
CM message identifiers used by the discovery session.
const ( // EMsgClientHello identifies the initial CM client hello message. EMsgClientHello uint32 = 9805 // EMsgServiceMethodCallFromClientNonAuthed identifies a pre-login UM call. EMsgServiceMethodCallFromClientNonAuthed uint32 = 9804 )
const NoJobID uint64 = ^uint64(0)
NoJobID is the reserved Steam value used when a message has no job ID.
Variables ¶
This section is empty.
Functions ¶
func EncodeFrame ¶
func EncodeFrame(frame Frame, limits FrameLimits) ([]byte, error)
EncodeFrame serializes a CM frame using the little-endian CM envelope.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client manages one CM WebSocket connection.
func (*Client) CallUnauthenticated ¶
func (c *Client) CallUnauthenticated(ctx context.Context, method string, body []byte) (Message, error)
CallUnauthenticated calls a Steam Unified Messaging method before CM logon. Calls are serialized because this operation owns socket reads.
func (*Client) Connect ¶
Connect opens a WebSocket to endpoint. The client supports one active connection at a time.
func (*Client) LogonAnonymous ¶
LogonAnonymous performs the anonymous ClientLogon exchange and starts the session heartbeat when the server supplies a positive interval.
func (*Client) LogonToken ¶
LogonToken starts an individual SteamClient session using a refresh token.
type ClientOption ¶
type ClientOption func(*clientConfig) error
ClientOption configures a CM client.
func WithFrameLimits ¶
func WithFrameLimits(limits FrameLimits) ClientOption
WithFrameLimits configures CM frame decoding and encoding limits.
func WithWebSocketOption ¶
func WithWebSocketOption(option WebSocketOption) ClientOption
WithWebSocketOption passes an option to the CM WebSocket dialer.
type DirectoryError ¶
type DirectoryError struct {
Message string
}
DirectoryError reports an error returned by the directory API.
func (*DirectoryError) Error ¶
func (e *DirectoryError) Error() string
type DirectoryQuery ¶
type DirectoryQuery struct {
CMType string
Realm string
CellID uint32
MaxCount uint32
QoSLevel uint32
}
DirectoryQuery contains filters accepted by GetCMListForConnect.
type Endpoint ¶
type Endpoint struct {
Address string `json:"endpoint" yaml:"endpoint"`
Legacy string `json:"legacy_endpoint,omitempty" yaml:"legacy_endpoint,omitempty"`
Type string `json:"type,omitempty" yaml:"type,omitempty"`
DataCenter string `json:"dc,omitempty" yaml:"dc,omitempty"`
Realm string `json:"realm,omitempty" yaml:"realm,omitempty"`
Load int32 `json:"load,omitempty" yaml:"load,omitempty"`
WeightedLoad float64 `json:"wtd_load,omitempty" yaml:"wtd_load,omitempty"`
}
Endpoint is a CM endpoint returned by the public directory.
type Frame ¶
Frame is one CM message after WebSocket framing has been removed.
func DecodeFrame ¶
func DecodeFrame(encoded []byte, limits FrameLimits) (Frame, error)
DecodeFrame parses one complete CM envelope and copies its payloads.
func DecodeMulti ¶
func DecodeMulti(frame Frame, limits MultiLimits) ([]Frame, error)
DecodeMulti expands one EMsg.Multi frame into its child frames.
type FrameLimits ¶
FrameLimits bounds allocations performed by DecodeFrame.
type Header ¶
type Header struct {
TargetJobName string
ErrorMessage string
SteamID uint64
JobIDSource uint64
JobIDTarget uint64
ClientSessionID int32
EResult int32
HasEResult bool
}
Header is the public subset of CMsgProtoBufHeader used by CM jobs.
type JobRequest ¶
type JobRequest struct {
TargetJobName string
Body []byte
EMsg uint32
ExpectedEMsg uint32
RequireEResult bool
}
JobRequest describes one protobuf CM job. Body must contain the request protobuf payload; response decoding belongs to the transport-specific package.
type LogoffError ¶
LogoffError reports a server-initiated CM session termination.
func (*LogoffError) Error ¶
func (e *LogoffError) Error() string
type LogonError ¶
LogonError reports a non-success EResult from ClientLogonResponse.
func (*LogonError) Error ¶
func (e *LogonError) Error() string
type MissingEResultError ¶
type MissingEResultError struct{}
MissingEResultError reports a CM job response without an EResult field when the request requires one.
func (MissingEResultError) Error ¶
func (MissingEResultError) Error() string
type MultiLimits ¶
type MultiLimits struct {
MaxUncompressedBytes int
MaxMessages int
MaxDepth int
FrameLimits FrameLimits
}
MultiLimits bounds decompression and recursive multipart expansion.
type Session ¶
type Session struct {
// WebSocketConn is the transport used by this authenticated session.
WebSocketConn *WebSocketConn
// SessionState exposes the Steam identity and heartbeat settings negotiated at logon.
SessionState
// contains filtered or unexported fields
}
Session is an authenticated CM session.
type SessionState ¶
type SessionState struct {
SteamID uint64
HeartbeatInterval time.Duration
SessionID int32
CellID uint32
}
SessionState contains the identity and timing values assigned by CM.
type TokenLogonDetails ¶
type TokenLogonDetails struct {
AccountName string
RefreshToken string `json:"-" yaml:"-"`
SteamID uint64
LoginID uint32
}
TokenLogonDetails contains the identity and SteamClient refresh token for an individual CM logon. LoginID must be unique for concurrent sessions from the same public IP; zero asks the client to generate one.
func (TokenLogonDetails) GoString ¶
func (TokenLogonDetails) GoString() string
GoString redacts the refresh token when details are formatted with %#v.
func (TokenLogonDetails) String ¶
func (TokenLogonDetails) String() string
String redacts the refresh token when details are formatted.
type WebSocketConn ¶
type WebSocketConn struct {
// contains filtered or unexported fields
}
WebSocketConn carries framed CM messages over a WebSocket. One goroutine may read while one goroutine writes; writes are serialized internally.
func Dial ¶
func Dial(ctx context.Context, address string, opts ...WebSocketOption) (*WebSocketConn, error)
Dial opens a CM WebSocket. address may be a directory endpoint such as "cmp-fra.steamserver.net:27019" or a complete ws(s) URL.
func (*WebSocketConn) Close ¶
func (c *WebSocketConn) Close() error
Close closes the WebSocket connection.
func (*WebSocketConn) ReadFrame ¶
func (c *WebSocketConn) ReadFrame(ctx context.Context, limits FrameLimits) (Frame, error)
ReadFrame reads and decodes one binary CM WebSocket message.
func (*WebSocketConn) WriteFrame ¶
func (c *WebSocketConn) WriteFrame(ctx context.Context, frame Frame, limits FrameLimits) error
WriteFrame encodes and sends one binary CM WebSocket message.
type WebSocketOption ¶
type WebSocketOption func(*webSocketConfig) error
WebSocketOption configures a CM WebSocket connection.
func WithHandshakeTimeout ¶
func WithHandshakeTimeout(timeout time.Duration) WebSocketOption
WithHandshakeTimeout bounds the WebSocket HTTP handshake.
func WithHeader ¶
func WithHeader(key, value string) WebSocketOption
WithHeader adds a header to the WebSocket handshake.
func WithIOTimeout ¶
func WithIOTimeout(timeout time.Duration) WebSocketOption
WithIOTimeout bounds one WebSocket read or write when the context has no earlier deadline.
func WithMessageSize ¶
func WithMessageSize(size int64) WebSocketOption
WithMessageSize limits one incoming WebSocket message.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package auth implements SteamClient authentication over a pre-login CM connection.
|
Package auth implements SteamClient authentication over a pre-login CM connection. |
|
Package gameservers implements Steam CM gameserver discovery methods.
|
Package gameservers implements Steam CM gameserver discovery methods. |
|
internal
|
|