package mtproto
import (
"context"
"github.com/go-faster/errors"
"github.com/gotd/log"
"github.com/gotd/td/bin"
"github.com/gotd/td/mt"
"github.com/gotd/td/proto"
"github.com/gotd/td/tgerr"
)
func (c *Conn ) handleResult (b *bin .Buffer ) error {
ctx := context .Background ()
var res proto .Result
if err := res .Decode (b ); err != nil {
return errors .Wrap (err , "decode" )
}
b .ResetTo (res .Result )
msgID := log .Int64 ("msg_id" , res .RequestMessageID )
c .logWithBuffer (b ).Debug (ctx , "Handle result" , msgID )
id , err := b .PeekID ()
if err != nil {
return err
}
if id == proto .GZIPTypeID {
content , err := gzip (b )
if err != nil {
return errors .Wrap (err , "decompress" )
}
b = content
c .logWithBuffer (b ).Debug (ctx , "Decompressed" , msgID )
if id , err = b .PeekID (); err != nil {
return errors .Wrap (err , "peek id" )
}
}
if id == mt .RPCErrorTypeID {
var rpcErr mt .RPCError
if err := rpcErr .Decode (b ); err != nil {
return errors .Wrap (err , "error decode" )
}
c .log .Debug (ctx , "Got error" , msgID ,
log .Int ("err_code" , rpcErr .ErrorCode ),
log .String ("err_msg" , rpcErr .ErrorMessage ),
)
c .rpc .NotifyError (res .RequestMessageID , tgerr .New (rpcErr .ErrorCode , rpcErr .ErrorMessage ))
return nil
}
if id == mt .PongTypeID {
return c .handlePong (b )
}
return c .rpc .NotifyResult (res .RequestMessageID , b )
}
The pages are generated with Golds v0.8.4 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .