Refactor: Rename Connection to Conn, add proxy example, and enhance login client functionality

This commit is contained in:
adman
2025-11-12 01:19:45 +01:00
parent f91424236b
commit 275f28a7c8
7 changed files with 203 additions and 39 deletions
+13 -3
View File
@@ -29,8 +29,10 @@ type Account struct {
Token string
}
type LoginClient struct {
*strom.Connection
*strom.Conn
Account Account
GivenAccount v1_21_8.LoginToClientPacketSuccess
}
func (s *LoginClient) Default(event any) (err error) {
@@ -124,7 +126,7 @@ func JoinServerAPI(a Account, serverId string) (err error) {
if err != nil {
return
}
err = fmt.Errorf("bad status code %v body %v", resp.StatusCode, string(body))
err = fmt.Errorf("bad client code %v body %v", resp.StatusCode, string(body))
return
}
return
@@ -187,11 +189,19 @@ func (s *LoginClient) OnEncrypt(packet v1_21_8.LoginToClientPacketEncryptionBegi
}
func (s *LoginClient) OnSuccess(success v1_21_8.LoginToClientPacketSuccess) (err error) {
fmt.Println("login success", success)
s.GivenAccount = success
err = s.Send(v1_21_8.LoginToServerPacketLoginAcknowledged{})
if err != nil {
return
}
s.State = queser.Configuration
err = strom.HandlerDone
return
}
func Login(c *strom.Conn, account Account) (err error) {
return c.Start(&LoginClient{
Conn: c,
Account: account,
})
}
+1 -1
View File
@@ -12,7 +12,7 @@ import (
)
type StatusClient struct {
*strom.Connection
*strom.Conn
Status string
}