代码拉取完成,页面将自动刷新
// Generated by the go idl tools. DO NOT EDIT 2022-03-17 11:27:42
// source: box_example
package example
import (
"gitee.com/dennis-kk/rpc-go-backend/idlrpc"
"time"
)
type testSubInfo struct {
subID string
event string
byte []byte
}
type TestCallerImpl struct {
name string
subInfo []*testSubInfo
}
func (sp *TestCallerImpl) OnSubscribe(subID string, event string, bytes []byte) error {
sp.subInfo = append(sp.subInfo, &testSubInfo{
subID: subID,
event: event,
byte: bytes,
})
return nil
}
func (sp *TestCallerImpl) OnCancel(subID string, event string) error {
if sp.subInfo[0].subID == subID && sp.subInfo[0].event == event {
sp.subInfo = nil
}
return nil
}
func (sp *TestCallerImpl) testEventCallback(event string, data []byte) {
}
func NewTestCaller() *TestCallerImpl {
service := &TestCallerImpl{
subInfo: make([]*testSubInfo, 0, 10),
}
return service
}
func (sp *TestCallerImpl) GetUUID() uint64 {
return 6784101236246863201
}
func (sp *TestCallerImpl) GetNickName() string {
return "6784101236246863201"
}
func (sp *TestCallerImpl) OnAfterFork(ctx idlrpc.IServiceContext) bool {
//add this service to framework, do not call rpc method in this function
return true
}
func (sp *TestCallerImpl) OnTick() bool {
//tick function in main goroutine
return true
}
func (sp *TestCallerImpl) OnBeforeDestroy() bool {
//tick function in main goroutine
return true
}
func (sp *TestCallerImpl) SetInfo(ctx idlrpc.IServiceContext, option string) (err error) {
switch option {
case "timeout":
// 休眠一秒
time.Sleep(time.Second)
sp.name = option
default:
sp.name = option
}
return
}
func (sp *TestCallerImpl) GetInfo(ctx idlrpc.IServiceContext) (ret1 string, err error) {
// 设置不立即返回
ctx.Continue()
go func() {
// 休眠0.5秒,然后返回
time.Sleep(time.Millisecond * 300)
_ = ctx.Finish("return_plato", nil)
}()
return "", nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。