Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
refactor: standardize around steamid.SteamId
Browse files Browse the repository at this point in the history
  • Loading branch information
paralin committed Jan 30, 2018
1 parent 3074a87 commit 60c03ca
Show file tree
Hide file tree
Showing 15 changed files with 367 additions and 274 deletions.
4 changes: 2 additions & 2 deletions auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
. "github.com/faceit/go-steam/protocol"
. "github.com/faceit/go-steam/protocol/protobuf"
. "github.com/faceit/go-steam/protocol/steamlang"
. "github.com/faceit/go-steam/steamid"
"github.com/faceit/go-steam/steamid"
"github.com/golang/protobuf/proto"
"sync/atomic"
"time"
Expand Down Expand Up @@ -51,7 +51,7 @@ func (a *Auth) LogOn(details *LogOnDetails) {
logon.ProtocolVersion = proto.Uint32(MsgClientLogon_CurrentProtocol)
logon.ShaSentryfile = details.SentryFileHash

atomic.StoreUint64(&a.client.steamId, uint64(NewIdAdv(0, 1, int32(EUniverse_Public), int32(EAccountType_Individual))))
atomic.StoreUint64(&a.client.steamId, steamid.NewIdAdv(0, 1, int32(EUniverse_Public), EAccountType_Individual).ToUint64())

a.client.Write(NewClientMsgProtobuf(EMsg_ClientLogon, logon))
}
Expand Down
1 change: 0 additions & 1 deletion auth_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package steam
import (
. "github.com/faceit/go-steam/protocol/protobuf"
. "github.com/faceit/go-steam/protocol/steamlang"
. "github.com/faceit/go-steam/steamid"
)

type LoggedOnEvent struct {
Expand Down
11 changes: 7 additions & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
. "github.com/faceit/go-steam/protocol"
. "github.com/faceit/go-steam/protocol/protobuf"
. "github.com/faceit/go-steam/protocol/steamlang"
. "github.com/faceit/go-steam/steamid"
"github.com/faceit/go-steam/steamid"
)

// Represents a client to the Steam network.
Expand Down Expand Up @@ -108,14 +108,17 @@ func (c *Client) RegisterPacketHandler(handler PacketHandler) {
c.handlers = append(c.handlers, handler)
}

// GetNextJobId returns the next job ID to use.
func (c *Client) GetNextJobId() JobId {
return JobId(atomic.AddUint64(&c.currentJobId, 1))
}

func (c *Client) SteamId() SteamId {
return SteamId(atomic.LoadUint64(&c.steamId))
// SteamId returns the client's steam ID.
func (c *Client) SteamId() steamid.SteamId {
return steamid.SteamId(atomic.LoadUint64(&c.steamId))
}

// SessionId returns the session id.
func (c *Client) SessionId() int32 {
return atomic.LoadInt32(&c.sessionId)
}
Expand Down Expand Up @@ -191,7 +194,7 @@ func (c *Client) Disconnect() {
func (c *Client) Write(msg IMsg) {
if cm, ok := msg.(IClientMsg); ok {
cm.SetSessionId(c.SessionId())
cm.SetSteamId(c.SteamId())
cm.SetSteamId(SteamId(c.SteamId()))
}
c.mutex.RLock()
defer c.mutex.RUnlock()
Expand Down
3 changes: 1 addition & 2 deletions protocol/msg.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package protocol

import (
"github.com/golang/protobuf/proto"
. "github.com/faceit/go-steam/protocol/steamlang"
. "github.com/faceit/go-steam/steamid"
"github.com/golang/protobuf/proto"
"io"
)

Expand Down
Loading

0 comments on commit 60c03ca

Please sign in to comment.