diff options
| author | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2024-06-17 20:30:49 -0700 |
|---|---|---|
| committer | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2024-06-17 20:30:49 -0700 |
| commit | 153e2eac3b51a6a426556752fa2c532cfe53f026 (patch) | |
| tree | df83911537b02f61396ecbca5c4796fd0c3db958 /hotline/client_conn.go | |
| parent | f8e4cd540b87de3e308ec18a2b040b284a741522 (diff) | |
Use fixed size array types in Transaction fields
Diffstat (limited to 'hotline/client_conn.go')
| -rw-r--r-- | hotline/client_conn.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/hotline/client_conn.go b/hotline/client_conn.go index c886dfc..0a7768f 100644 --- a/hotline/client_conn.go +++ b/hotline/client_conn.go @@ -54,7 +54,7 @@ func (cc *ClientConn) sendAll(t int, fields ...Field) { } func (cc *ClientConn) handleTransaction(transaction Transaction) error { - requestNum := binary.BigEndian.Uint16(transaction.Type) + requestNum := binary.BigEndian.Uint16(transaction.Type[:]) if handler, ok := TransactionHandlers[requestNum]; ok { for _, reqField := range handler.RequiredFields { field := transaction.GetField(reqField.ID) @@ -168,10 +168,10 @@ func (cc *ClientConn) notifyOthers(t Transaction) (trans []Transaction) { func (cc *ClientConn) NewReply(t *Transaction, fields ...Field) Transaction { return Transaction{ IsReply: 0x01, - Type: []byte{0x00, 0x00}, + Type: [2]byte{0x00, 0x00}, ID: t.ID, clientID: cc.ID, - ErrorCode: []byte{0, 0, 0, 0}, + ErrorCode: [4]byte{0, 0, 0, 0}, Fields: fields, } } @@ -181,9 +181,9 @@ func (cc *ClientConn) NewErrReply(t *Transaction, errMsg string) Transaction { return Transaction{ clientID: cc.ID, IsReply: 0x01, - Type: []byte{0, 0}, + Type: [2]byte{0, 0}, ID: t.ID, - ErrorCode: []byte{0, 0, 0, 1}, + ErrorCode: [4]byte{0, 0, 0, 1}, Fields: []Field{ NewField(FieldError, []byte(errMsg)), }, |