github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/protocol/keybase1/session.go (about)

     1  // Auto-generated to Go types and interfaces using avdl-compiler v1.4.10 (https://github.com/keybase/node-avdl-compiler)
     2  //   Input file: avdl/keybase1/session.avdl
     3  
     4  package keybase1
     5  
     6  import (
     7  	"github.com/keybase/go-framed-msgpack-rpc/rpc"
     8  	context "golang.org/x/net/context"
     9  	"time"
    10  )
    11  
    12  type Session struct {
    13  	Uid             UID    `codec:"uid" json:"uid"`
    14  	Username        string `codec:"username" json:"username"`
    15  	Token           string `codec:"token" json:"token"`
    16  	DeviceSubkeyKid KID    `codec:"deviceSubkeyKid" json:"deviceSubkeyKid"`
    17  	DeviceSibkeyKid KID    `codec:"deviceSibkeyKid" json:"deviceSibkeyKid"`
    18  }
    19  
    20  func (o Session) DeepCopy() Session {
    21  	return Session{
    22  		Uid:             o.Uid.DeepCopy(),
    23  		Username:        o.Username,
    24  		Token:           o.Token,
    25  		DeviceSubkeyKid: o.DeviceSubkeyKid.DeepCopy(),
    26  		DeviceSibkeyKid: o.DeviceSibkeyKid.DeepCopy(),
    27  	}
    28  }
    29  
    30  type CurrentSessionArg struct {
    31  	SessionID int `codec:"sessionID" json:"sessionID"`
    32  }
    33  
    34  type SessionPingArg struct {
    35  }
    36  
    37  type SessionInterface interface {
    38  	CurrentSession(context.Context, int) (Session, error)
    39  	SessionPing(context.Context) error
    40  }
    41  
    42  func SessionProtocol(i SessionInterface) rpc.Protocol {
    43  	return rpc.Protocol{
    44  		Name: "keybase.1.session",
    45  		Methods: map[string]rpc.ServeHandlerDescription{
    46  			"currentSession": {
    47  				MakeArg: func() interface{} {
    48  					var ret [1]CurrentSessionArg
    49  					return &ret
    50  				},
    51  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
    52  					typedArgs, ok := args.(*[1]CurrentSessionArg)
    53  					if !ok {
    54  						err = rpc.NewTypeError((*[1]CurrentSessionArg)(nil), args)
    55  						return
    56  					}
    57  					ret, err = i.CurrentSession(ctx, typedArgs[0].SessionID)
    58  					return
    59  				},
    60  			},
    61  			"sessionPing": {
    62  				MakeArg: func() interface{} {
    63  					var ret [1]SessionPingArg
    64  					return &ret
    65  				},
    66  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
    67  					err = i.SessionPing(ctx)
    68  					return
    69  				},
    70  			},
    71  		},
    72  	}
    73  }
    74  
    75  type SessionClient struct {
    76  	Cli rpc.GenericClient
    77  }
    78  
    79  func (c SessionClient) CurrentSession(ctx context.Context, sessionID int) (res Session, err error) {
    80  	__arg := CurrentSessionArg{SessionID: sessionID}
    81  	err = c.Cli.Call(ctx, "keybase.1.session.currentSession", []interface{}{__arg}, &res, 0*time.Millisecond)
    82  	return
    83  }
    84  
    85  func (c SessionClient) SessionPing(ctx context.Context) (err error) {
    86  	err = c.Cli.Call(ctx, "keybase.1.session.sessionPing", []interface{}{SessionPingArg{}}, nil, 0*time.Millisecond)
    87  	return
    88  }