/
rpc_client_registers.go
56 lines (46 loc) · 2.16 KB
/
rpc_client_registers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* WARNING! All changes made in this file will be lost!
* Created from 'scheme.tl' by 'mtprotoc'
*
* Copyright (c) 2023-present, Teamgram Authors.
* All rights reserved.
*
* Author: Benqi (wubenqi@gmail.com)
*/
package session
import (
"reflect"
"github.com/teamgram/proto/mtproto"
)
var _ *mtproto.Bool
type newRPCReplyFunc func() interface{}
type RPCContextTuple struct {
Method string
NewReplyFunc newRPCReplyFunc
}
var rpcContextRegisters = map[string]RPCContextTuple{
"TLSessionQueryAuthKey": RPCContextTuple{"/mtproto.RPCSession/session_queryAuthKey", func() interface{} { return new(mtproto.AuthKeyInfo) }},
"TLSessionSetAuthKey": RPCContextTuple{"/mtproto.RPCSession/session_setAuthKey", func() interface{} { return new(mtproto.Bool) }},
"TLSessionCreateSession": RPCContextTuple{"/mtproto.RPCSession/session_createSession", func() interface{} { return new(mtproto.Bool) }},
"TLSessionSendDataToSession": RPCContextTuple{"/mtproto.RPCSession/session_sendDataToSession", func() interface{} { return new(mtproto.Bool) }},
"TLSessionSendHttpDataToSession": RPCContextTuple{"/mtproto.RPCSession/session_sendHttpDataToSession", func() interface{} { return new(HttpSessionData) }},
"TLSessionCloseSession": RPCContextTuple{"/mtproto.RPCSession/session_closeSession", func() interface{} { return new(mtproto.Bool) }},
"TLSessionPushUpdatesData": RPCContextTuple{"/mtproto.RPCSession/session_pushUpdatesData", func() interface{} { return new(mtproto.Bool) }},
"TLSessionPushSessionUpdatesData": RPCContextTuple{"/mtproto.RPCSession/session_pushSessionUpdatesData", func() interface{} { return new(mtproto.Bool) }},
"TLSessionPushRpcResultData": RPCContextTuple{"/mtproto.RPCSession/session_pushRpcResultData", func() interface{} { return new(mtproto.Bool) }},
}
func FindRPCContextTuple(t interface{}) *RPCContextTuple {
rt := reflect.TypeOf(t)
if rt.Kind() == reflect.Ptr {
rt = rt.Elem()
}
m, ok := rpcContextRegisters[rt.Name()]
if !ok {
// log.Errorf("Can't find name: %s", rt.Name())
return nil
}
return &m
}
func GetRPCContextRegisters() map[string]RPCContextTuple {
return rpcContextRegisters
}