]> git.r.bdr.sh - rbdr/mobius/blobdiff - hotline/client.go
Extensive refactor, quality of life enhancements
[rbdr/mobius] / hotline / client.go
index 2389ee59b52118a1bcde343722f3b92ef932d1dd..e300bb8bb61485ea5d510353cb7a6a36b21e4734 100644 (file)
@@ -31,6 +31,7 @@ type Client struct {
        Pref        *ClientPrefs
        Handlers    map[[2]byte]ClientHandler
        activeTasks map[[4]byte]*Transaction
+       UserList    []User
 }
 
 type ClientHandler func(context.Context, *Client, *Transaction) ([]Transaction, error)
@@ -83,8 +84,8 @@ func (c *Client) Connect(address, login, passwd string) (err error) {
                        TranLogin, [2]byte{0, 0},
                        NewField(FieldUserName, []byte(c.Pref.Username)),
                        NewField(FieldUserIconID, c.Pref.IconBytes()),
-                       NewField(FieldUserLogin, encodeString([]byte(login))),
-                       NewField(FieldUserPassword, encodeString([]byte(passwd))),
+                       NewField(FieldUserLogin, EncodeString([]byte(login))),
+                       NewField(FieldUserPassword, EncodeString([]byte(passwd))),
                ),
        )
        if err != nil {
@@ -119,8 +120,8 @@ var ServerHandshake = []byte{
 }
 
 func (c *Client) Handshake() error {
-       // Protocol ID  4       ‘TRTP’      0x54 52 54 50
-       // Sub-protocol ID      4               User defined
+       // Protocol Type        4       ‘TRTP’      0x54 52 54 50
+       // Sub-protocol Type    4               User defined
        // Version      2       1       Currently 1
        // Sub-version  2               User defined
        if _, err := c.Connection.Write(ClientHandshake); err != nil {
@@ -184,12 +185,6 @@ func (c *Client) HandleTransaction(ctx context.Context, t *Transaction) error {
                                return err
                        }
                }
-       } else {
-               c.Logger.Debug(
-                       "Unimplemented transaction type",
-                       "IsReply", t.IsReply,
-                       "type", t.Type[:],
-               )
        }
 
        return nil