-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add handler for multi messages, move logon to user
- Loading branch information
1 parent
b3c1e97
commit 136fce0
Showing
5 changed files
with
148 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
module vapor | ||
|
||
import emily33901.archive | ||
|
||
import proto | ||
|
||
struct MultiHandler { | ||
mut: | ||
s &SteamClient | ||
} | ||
|
||
pub fn (mut h MultiHandler) initialise(mut s SteamClient) ? { | ||
h.s = s | ||
} | ||
|
||
pub fn (mut h MultiHandler) handle_msg(m Message) ? { | ||
if m.msg == .multi { | ||
multi := proto.cmsgmulti_unpack(m.body)? | ||
|
||
mut body := multi.message_body | ||
|
||
if multi.size_unzipped > 0 { | ||
body = archive.deflate(multi.message_body, int(multi.size_unzipped))? | ||
} | ||
|
||
for i := 0; i < body.len; { | ||
size := *&int(body[i..].data) | ||
i += 4 | ||
inner_body := body[i..i+size] | ||
|
||
h.s.process_and_dispatch_packet(Packet{ body: inner_body })? | ||
|
||
i += size | ||
} | ||
|
||
body.free() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
module vapor | ||
|
||
struct SteamFriends { | ||
mut: | ||
s &SteamClient | ||
} | ||
|
||
pub fn (mut s SteamFriends) initialise() ? { | ||
|
||
pub fn (mut f SteamFriends) initialise(mut s SteamClient) ? { | ||
f.s = s | ||
} | ||
|
||
pub fn (mut s SteamFriends) handle_msg(mut m Message) ? { | ||
pub fn (mut f SteamFriends) handle_msg(m Message) ? { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
module vapor | ||
|
||
import proto | ||
|
||
struct SteamUser { | ||
mut: | ||
s &SteamClient | ||
} | ||
|
||
pub fn (mut user SteamUser) initialise(mut s SteamClient) ? { | ||
user.s = s | ||
} | ||
|
||
pub fn (mut user SteamUser) handle_msg(m Message) ? { | ||
match m.msg { | ||
.client_log_on_response { | ||
// TODO remove | ||
message := proto.cmsgclientlogonresponse_unpack(m.body)? | ||
|
||
println('$message') | ||
println('$message.eresult') | ||
} | ||
else {} | ||
} | ||
} | ||
|
||
pub fn (mut user SteamUser) logon(username, password string) ? { | ||
mut logon_message := proto.CMsgClientLogon{} | ||
|
||
logon_message.has_protocol_version = true | ||
// TODO a bump to 65580 means we go from zip -> gzip compression | ||
logon_message.protocol_version = 65575 | ||
|
||
logon_message.has_account_name = true | ||
logon_message.account_name = username | ||
|
||
logon_message.has_password = true | ||
logon_message.password = password | ||
|
||
logon_message.has_cell_id = true | ||
logon_message.cell_id = 4 | ||
|
||
user.s.write_message(0, .client_logon, &logon_message) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters