X-Git-Url: https://git.r.bdr.sh/rbdr/mobius/blobdiff_plain/95b51279959956123f87f798d93ee7f1521c0caa..da5bdd82beef668f49c2cec09cea85435c0bec34:/hotline/client.go?ds=sidebyside diff --git a/hotline/client.go b/hotline/client.go index 3676560..c322562 100644 --- a/hotline/client.go +++ b/hotline/client.go @@ -119,7 +119,7 @@ func (db *DebugBuffer) Write(p []byte) (int, error) { return db.TextView.Write(p) } -// Sync is a noop function that exists to satisfy the zapcore.WriteSyncer interface +// Sync is a noop function that dataFile to satisfy the zapcore.WriteSyncer interface func (db *DebugBuffer) Sync() error { return nil } @@ -397,54 +397,6 @@ func handleNotifyDeleteUser(c *Client, t *Transaction) (res []Transaction, err e return res, err } -const readBuffSize = 1024000 // 1KB - TODO: what should this be? - -func (c *Client) ReadLoop() error { - tranBuff := make([]byte, 0) - tReadlen := 0 - // Infinite loop where take action on incoming client requests until the connection is closed - for { - buf := make([]byte, readBuffSize) - tranBuff = tranBuff[tReadlen:] - - readLen, err := c.Connection.Read(buf) - if err != nil { - return err - } - tranBuff = append(tranBuff, buf[:readLen]...) - - // We may have read multiple requests worth of bytes from Connection.Read. readTransactions splits them - // into a slice of transactions - var transactions []Transaction - if transactions, tReadlen, err = readTransactions(tranBuff); err != nil { - c.Logger.Errorw("Error handling transaction", "err", err) - } - - // iterate over all of the transactions that were parsed from the byte slice and handle them - for _, t := range transactions { - if err := c.HandleTransaction(&t); err != nil { - c.Logger.Errorw("Error handling transaction", "err", err) - } - } - } -} - -func (c *Client) GetTransactions() error { - tranBuff := make([]byte, 0) - tReadlen := 0 - - buf := make([]byte, readBuffSize) - tranBuff = tranBuff[tReadlen:] - - readLen, err := c.Connection.Read(buf) - if err != nil { - return err - } - tranBuff = append(tranBuff, buf[:readLen]...) - - return nil -} - func handleClientGetUserNameList(c *Client, t *Transaction) (res []Transaction, err error) { var users []User for _, field := range t.Fields { @@ -674,10 +626,7 @@ func (c *Client) HandleTransaction(t *Transaction) error { } requestNum := binary.BigEndian.Uint16(t.Type) - c.Logger.Infow( - "Received Transaction", - "RequestType", requestNum, - ) + c.Logger.Debugw("Received Transaction", "RequestType", requestNum) if handler, ok := c.Handlers[requestNum]; ok { outT, _ := handler.Handle(c, t)