上传聊天服务代码
This commit is contained in:
parent
5f83525eeb
commit
335aa7284b
27
bin/json/game_chatchannel.json
Normal file
27
bin/json/game_chatchannel.json
Normal file
@ -0,0 +1,27 @@
|
||||
[
|
||||
{
|
||||
"key": "channel_lock_world",
|
||||
"tag_list": 1,
|
||||
"speak_cd": 5
|
||||
},
|
||||
{
|
||||
"key": "channel_lock_guild",
|
||||
"tag_list": 2,
|
||||
"speak_cd": 3
|
||||
},
|
||||
{
|
||||
"key": "channel_lock_private",
|
||||
"tag_list": 3,
|
||||
"speak_cd": 3
|
||||
},
|
||||
{
|
||||
"key": "channel_lock_public",
|
||||
"tag_list": 4,
|
||||
"speak_cd": 15
|
||||
},
|
||||
{
|
||||
"key": "channel_lock_system",
|
||||
"tag_list": 5,
|
||||
"speak_cd": 0
|
||||
}
|
||||
]
|
32
bin/json/game_chatchannelcom.json
Normal file
32
bin/json/game_chatchannelcom.json
Normal file
@ -0,0 +1,32 @@
|
||||
[
|
||||
{
|
||||
"key": "max_word",
|
||||
"value": 200,
|
||||
"dec": "输入框最大字数为value"
|
||||
},
|
||||
{
|
||||
"key": "max_chat",
|
||||
"value": 99,
|
||||
"dec": "最大保存条数为value"
|
||||
},
|
||||
{
|
||||
"key": "max_object",
|
||||
"value": 50,
|
||||
"dec": "最大私聊对象数为value"
|
||||
},
|
||||
{
|
||||
"key": "load_chat",
|
||||
"value": 10,
|
||||
"dec": "加入或切换跨服频道时,请求最近value条历史消息"
|
||||
},
|
||||
{
|
||||
"key": "channel_allocation_max",
|
||||
"value": 2000,
|
||||
"dec": "频道大于value人时不再继续分配"
|
||||
},
|
||||
{
|
||||
"key": "channel_switching_max",
|
||||
"value": 3000,
|
||||
"dec": "频道大于value人时不再接受手动切换到该频道"
|
||||
}
|
||||
]
|
82
bin/json/game_chatservergroup.json
Normal file
82
bin/json/game_chatservergroup.json
Normal file
@ -0,0 +1,82 @@
|
||||
[
|
||||
{
|
||||
"server": "dreamfactory_liwei",
|
||||
"group": 1
|
||||
},
|
||||
{
|
||||
"server": "2",
|
||||
"group": 1
|
||||
},
|
||||
{
|
||||
"server": "3",
|
||||
"group": 1
|
||||
},
|
||||
{
|
||||
"server": "4",
|
||||
"group": 1
|
||||
},
|
||||
{
|
||||
"server": "5",
|
||||
"group": 1
|
||||
},
|
||||
{
|
||||
"server": "6",
|
||||
"group": 1
|
||||
},
|
||||
{
|
||||
"server": "7",
|
||||
"group": 1
|
||||
},
|
||||
{
|
||||
"server": "8",
|
||||
"group": 1
|
||||
},
|
||||
{
|
||||
"server": "9",
|
||||
"group": 1
|
||||
},
|
||||
{
|
||||
"server": "10",
|
||||
"group": 2
|
||||
},
|
||||
{
|
||||
"server": "11",
|
||||
"group": 2
|
||||
},
|
||||
{
|
||||
"server": "12",
|
||||
"group": 2
|
||||
},
|
||||
{
|
||||
"server": "13",
|
||||
"group": 2
|
||||
},
|
||||
{
|
||||
"server": "14",
|
||||
"group": 2
|
||||
},
|
||||
{
|
||||
"server": "15",
|
||||
"group": 2
|
||||
},
|
||||
{
|
||||
"server": "16",
|
||||
"group": 2
|
||||
},
|
||||
{
|
||||
"server": "17",
|
||||
"group": 2
|
||||
},
|
||||
{
|
||||
"server": "18",
|
||||
"group": 2
|
||||
},
|
||||
{
|
||||
"server": "19",
|
||||
"group": 2
|
||||
},
|
||||
{
|
||||
"server": "20",
|
||||
"group": 2
|
||||
}
|
||||
]
|
143
bin/json/game_chatsystem.json
Normal file
143
bin/json/game_chatsystem.json
Normal file
@ -0,0 +1,143 @@
|
||||
[
|
||||
{
|
||||
"key": 10001,
|
||||
"type": 1,
|
||||
"title": "【系统】",
|
||||
"close": "#ff3f3f",
|
||||
"test": "阿宝转转转活动还有3分钟开始了!",
|
||||
"data": 0,
|
||||
"week": [
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7
|
||||
],
|
||||
"time_h": 15,
|
||||
"time_m": 57
|
||||
},
|
||||
{
|
||||
"key": 10002,
|
||||
"type": 1,
|
||||
"title": "【系统】",
|
||||
"close": "#ff3f3f",
|
||||
"test": "阿宝转转转活动还有2分钟开始了!",
|
||||
"data": 0,
|
||||
"week": [
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5
|
||||
],
|
||||
"time_h": 15,
|
||||
"time_m": 58
|
||||
},
|
||||
{
|
||||
"key": 10003,
|
||||
"type": 1,
|
||||
"title": "【系统】",
|
||||
"close": "#ff3f3f",
|
||||
"test": "阿宝转转转活动还有1分钟开始了!",
|
||||
"data": 0,
|
||||
"week": [
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5
|
||||
],
|
||||
"time_h": 15,
|
||||
"time_m": 59
|
||||
},
|
||||
{
|
||||
"key": 20001,
|
||||
"type": 2,
|
||||
"title": "【传闻】",
|
||||
"close": "#ffc73f",
|
||||
"test": "[name]经过不懈努力,将[item]强化到了\u002B[data]!",
|
||||
"data": 12,
|
||||
"week": [],
|
||||
"time_h": 0,
|
||||
"time_m": 0
|
||||
},
|
||||
{
|
||||
"key": 20002,
|
||||
"type": 2,
|
||||
"title": "【传闻】",
|
||||
"close": "#ffc73f",
|
||||
"test": "[name]经过不懈努力,将[item]强化到了\u002B[data]!",
|
||||
"data": 13,
|
||||
"week": [],
|
||||
"time_h": 0,
|
||||
"time_m": 0
|
||||
},
|
||||
{
|
||||
"key": 20003,
|
||||
"type": 2,
|
||||
"title": "【传闻】",
|
||||
"close": "#ffc73f",
|
||||
"test": "[name]经过不懈努力,将[item]强化到了\u002B[data]!",
|
||||
"data": 14,
|
||||
"week": [],
|
||||
"time_h": 0,
|
||||
"time_m": 0
|
||||
},
|
||||
{
|
||||
"key": 20004,
|
||||
"type": 2,
|
||||
"title": "【传闻】",
|
||||
"close": "#ffc73f",
|
||||
"test": "[name]经过不懈努力,将[item]强化到了\u002B[data]!",
|
||||
"data": 15,
|
||||
"week": [],
|
||||
"time_h": 0,
|
||||
"time_m": 0
|
||||
},
|
||||
{
|
||||
"key": 30001,
|
||||
"type": 3,
|
||||
"title": "【传闻】",
|
||||
"close": "#ffc73f",
|
||||
"test": "[name]突破了时空塔第[data]层!",
|
||||
"data": 50,
|
||||
"week": [],
|
||||
"time_h": 0,
|
||||
"time_m": 0
|
||||
},
|
||||
{
|
||||
"key": 30002,
|
||||
"type": 3,
|
||||
"title": "【传闻】",
|
||||
"close": "#ffc73f",
|
||||
"test": "[name]突破了时空塔第[data]层!",
|
||||
"data": 100,
|
||||
"week": [],
|
||||
"time_h": 0,
|
||||
"time_m": 0
|
||||
},
|
||||
{
|
||||
"key": 30003,
|
||||
"type": 3,
|
||||
"title": "【传闻】",
|
||||
"close": "#ffc73f",
|
||||
"test": "[name]突破了时空塔第[data]层!",
|
||||
"data": 150,
|
||||
"week": [],
|
||||
"time_h": 0,
|
||||
"time_m": 0
|
||||
},
|
||||
{
|
||||
"key": 30004,
|
||||
"type": 3,
|
||||
"title": "【传闻】",
|
||||
"close": "#ffc73f",
|
||||
"test": "[name]突破了时空塔第[data]层!",
|
||||
"data": 200,
|
||||
"week": [],
|
||||
"time_h": 0,
|
||||
"time_m": 0
|
||||
}
|
||||
]
|
@ -111,249 +111,72 @@ func (this *Client) UnregisterAll() (err error) {
|
||||
|
||||
//同步调用
|
||||
func (this *Client) Call(ctx context.Context, servicePath string, serviceMethod string, args interface{}, reply interface{}) (err error) {
|
||||
if servicePath == "" {
|
||||
err = errors.New("servicePath no cant null")
|
||||
var (
|
||||
_client client.XClient
|
||||
)
|
||||
if _client, err = this.getclient(&ctx, this.options.ServiceTag, servicePath); err != nil {
|
||||
return
|
||||
}
|
||||
var (
|
||||
spath []string
|
||||
clients map[string]client.XClient
|
||||
d *client.ConsulDiscovery
|
||||
c client.XClient
|
||||
ok bool
|
||||
)
|
||||
spath = strings.Split(servicePath, "/")
|
||||
if clients, ok = this.clusterClients[this.options.ServiceTag]; !ok {
|
||||
this.clusterClients[this.options.ServiceTag] = make(map[string]client.XClient)
|
||||
clients = this.clusterClients[this.options.ServiceTag]
|
||||
} else {
|
||||
if c, ok = clients[spath[0]]; !ok {
|
||||
if d, err = client.NewConsulDiscovery(this.options.ServiceTag, spath[0], this.options.ConsulServers, nil); err != nil {
|
||||
return
|
||||
}
|
||||
c = client.NewBidirectionalXClient(spath[0], client.Failfast, client.RandomSelect, d, client.DefaultOption, this.msgChan)
|
||||
c.GetPlugins().Add(this)
|
||||
if this.options.RpcxStartType == RpcxStartByClient && this.options.AutoConnect {
|
||||
c.SetSelector(newSelector(this.UpdateServer))
|
||||
} else {
|
||||
c.SetSelector(newSelector(nil))
|
||||
}
|
||||
clients[spath[0]] = c
|
||||
}
|
||||
}
|
||||
ctx = context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{
|
||||
ServiceClusterTag: this.options.ServiceTag,
|
||||
CallRoutRulesKey: servicePath,
|
||||
ServiceAddrKey: "tcp@" + this.options.ServiceAddr,
|
||||
ServiceMetaKey: this.metadata,
|
||||
})
|
||||
err = c.Call(ctx, serviceMethod, args, reply)
|
||||
err = _client.Call(ctx, serviceMethod, args, reply)
|
||||
return
|
||||
}
|
||||
|
||||
//异步调用
|
||||
func (this *Client) Go(ctx context.Context, servicePath string, serviceMethod string, args interface{}, reply interface{}, done chan *client.Call) (call *client.Call, err error) {
|
||||
// return this.xclient.Go(ctx, string(serviceMethod), args, reply, done)
|
||||
if servicePath == "" {
|
||||
err = errors.New("servicePath no cant null")
|
||||
var (
|
||||
_client client.XClient
|
||||
)
|
||||
if _client, err = this.getclient(&ctx, this.options.ServiceTag, servicePath); err != nil {
|
||||
return
|
||||
}
|
||||
var (
|
||||
spath []string
|
||||
clients map[string]client.XClient
|
||||
d *client.ConsulDiscovery
|
||||
c client.XClient
|
||||
ok bool
|
||||
)
|
||||
spath = strings.Split(servicePath, "/")
|
||||
if clients, ok = this.clusterClients[this.options.ServiceTag]; !ok {
|
||||
this.clusterClients[this.options.ServiceTag] = make(map[string]client.XClient)
|
||||
clients = this.clusterClients[this.options.ServiceTag]
|
||||
} else {
|
||||
if c, ok = clients[spath[0]]; !ok {
|
||||
if d, err = client.NewConsulDiscovery(this.options.ServiceTag, spath[0], this.options.ConsulServers, nil); err != nil {
|
||||
return
|
||||
}
|
||||
c = client.NewXClient(spath[0], client.Failfast, client.RandomSelect, d, client.DefaultOption)
|
||||
c.GetPlugins().Add(this)
|
||||
c.SetSelector(newSelector(this.UpdateServer))
|
||||
clients[spath[0]] = c
|
||||
}
|
||||
}
|
||||
ctx = context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{
|
||||
ServiceClusterTag: this.options.ServiceTag,
|
||||
CallRoutRulesKey: servicePath,
|
||||
ServiceAddrKey: "tcp@" + this.options.ServiceAddr,
|
||||
ServiceMetaKey: this.metadata,
|
||||
})
|
||||
return c.Go(ctx, string(serviceMethod), args, reply, done)
|
||||
return _client.Go(ctx, string(serviceMethod), args, reply, done)
|
||||
}
|
||||
|
||||
//异步调用
|
||||
func (this *Client) Broadcast(ctx context.Context, servicePath string, serviceMethod string, args interface{}, reply interface{}) (err error) {
|
||||
if servicePath == "" {
|
||||
err = errors.New("servicePath no cant null")
|
||||
var (
|
||||
_client client.XClient
|
||||
)
|
||||
if _client, err = this.getclient(&ctx, this.options.ServiceTag, servicePath); err != nil {
|
||||
return
|
||||
}
|
||||
var (
|
||||
spath []string
|
||||
clients map[string]client.XClient
|
||||
d *client.ConsulDiscovery
|
||||
c client.XClient
|
||||
ok bool
|
||||
)
|
||||
spath = strings.Split(servicePath, "/")
|
||||
if clients, ok = this.clusterClients[this.options.ServiceTag]; !ok {
|
||||
this.clusterClients[this.options.ServiceTag] = make(map[string]client.XClient)
|
||||
clients = this.clusterClients[this.options.ServiceTag]
|
||||
} else {
|
||||
if c, ok = clients[spath[0]]; !ok {
|
||||
if d, err = client.NewConsulDiscovery(this.options.ServiceTag, spath[0], this.options.ConsulServers, nil); err != nil {
|
||||
return
|
||||
}
|
||||
c = client.NewBidirectionalXClient(spath[0], client.Failfast, client.RandomSelect, d, client.DefaultOption, this.msgChan)
|
||||
c.GetPlugins().Add(this)
|
||||
if this.options.RpcxStartType == RpcxStartByClient && this.options.AutoConnect {
|
||||
c.SetSelector(newSelector(this.UpdateServer))
|
||||
} else {
|
||||
c.SetSelector(newSelector(nil))
|
||||
}
|
||||
clients[spath[0]] = c
|
||||
}
|
||||
}
|
||||
ctx = context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{
|
||||
ServiceClusterTag: this.options.ServiceTag,
|
||||
CallRoutRulesKey: servicePath,
|
||||
ServiceAddrKey: "tcp@" + this.options.ServiceAddr,
|
||||
ServiceMetaKey: this.metadata,
|
||||
})
|
||||
err = c.Broadcast(ctx, serviceMethod, args, reply)
|
||||
err = _client.Broadcast(ctx, serviceMethod, args, reply)
|
||||
return
|
||||
}
|
||||
|
||||
//跨集群 同步调用
|
||||
func (this *Client) AcrossClusterCall(ctx context.Context, clusterTag string, servicePath string, serviceMethod string, args interface{}, reply interface{}) (err error) {
|
||||
if servicePath == "" {
|
||||
err = errors.New("servicePath no cant null")
|
||||
var (
|
||||
_client client.XClient
|
||||
)
|
||||
if _client, err = this.getclient(&ctx, clusterTag, servicePath); err != nil {
|
||||
return
|
||||
}
|
||||
var (
|
||||
spath []string
|
||||
clients map[string]client.XClient
|
||||
d *client.ConsulDiscovery
|
||||
c client.XClient
|
||||
ok bool
|
||||
)
|
||||
spath = strings.Split(servicePath, "/")
|
||||
if clients, ok = this.clusterClients[clusterTag]; !ok {
|
||||
this.clusterClients[clusterTag] = make(map[string]client.XClient)
|
||||
clients = this.clusterClients[clusterTag]
|
||||
} else {
|
||||
if c, ok = clients[spath[0]]; !ok {
|
||||
if d, err = client.NewConsulDiscovery(clusterTag, spath[0], this.options.ConsulServers, nil); err != nil {
|
||||
return
|
||||
}
|
||||
c = client.NewBidirectionalXClient(spath[0], client.Failfast, client.RandomSelect, d, client.DefaultOption, this.msgChan)
|
||||
c.GetPlugins().Add(this)
|
||||
if this.options.RpcxStartType == RpcxStartByClient && this.options.AutoConnect {
|
||||
c.SetSelector(newSelector(this.UpdateServer))
|
||||
} else {
|
||||
c.SetSelector(newSelector(nil))
|
||||
}
|
||||
clients[spath[0]] = c
|
||||
}
|
||||
}
|
||||
ctx = context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{
|
||||
ServiceClusterTag: clusterTag,
|
||||
CallRoutRulesKey: servicePath,
|
||||
ServiceAddrKey: "tcp@" + this.options.ServiceAddr,
|
||||
ServiceMetaKey: this.metadata,
|
||||
})
|
||||
err = c.Call(ctx, serviceMethod, args, reply)
|
||||
err = _client.Call(ctx, serviceMethod, args, reply)
|
||||
return
|
||||
}
|
||||
|
||||
//跨集群 异步调用
|
||||
func (this *Client) AcrossClusterGo(ctx context.Context, clusterTag string, servicePath string, serviceMethod string, args interface{}, reply interface{}, done chan *client.Call) (call *client.Call, err error) {
|
||||
if servicePath == "" {
|
||||
err = errors.New("servicePath no cant null")
|
||||
var (
|
||||
_client client.XClient
|
||||
)
|
||||
if _client, err = this.getclient(&ctx, clusterTag, servicePath); err != nil {
|
||||
return
|
||||
}
|
||||
var (
|
||||
spath []string
|
||||
clients map[string]client.XClient
|
||||
d *client.ConsulDiscovery
|
||||
c client.XClient
|
||||
ok bool
|
||||
)
|
||||
spath = strings.Split(servicePath, "/")
|
||||
if clients, ok = this.clusterClients[clusterTag]; !ok {
|
||||
this.clusterClients[clusterTag] = make(map[string]client.XClient)
|
||||
clients = this.clusterClients[clusterTag]
|
||||
} else {
|
||||
if c, ok = clients[spath[0]]; !ok {
|
||||
if d, err = client.NewConsulDiscovery(clusterTag, spath[0], this.options.ConsulServers, nil); err != nil {
|
||||
return
|
||||
}
|
||||
c = client.NewBidirectionalXClient(spath[0], client.Failfast, client.RandomSelect, d, client.DefaultOption, this.msgChan)
|
||||
c.GetPlugins().Add(this)
|
||||
if this.options.RpcxStartType == RpcxStartByClient && this.options.AutoConnect {
|
||||
c.SetSelector(newSelector(this.UpdateServer))
|
||||
} else {
|
||||
c.SetSelector(newSelector(nil))
|
||||
}
|
||||
clients[spath[0]] = c
|
||||
}
|
||||
}
|
||||
ctx = context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{
|
||||
ServiceClusterTag: this.options.ServiceTag,
|
||||
CallRoutRulesKey: servicePath,
|
||||
ServiceAddrKey: "tcp@" + this.options.ServiceAddr,
|
||||
ServiceMetaKey: this.metadata,
|
||||
})
|
||||
return c.Go(ctx, string(serviceMethod), args, reply, done)
|
||||
|
||||
return _client.Go(ctx, string(serviceMethod), args, reply, done)
|
||||
}
|
||||
|
||||
//跨集群 广播
|
||||
func (this *Client) AcrossClusterBroadcast(ctx context.Context, clusterTag string, servicePath string, serviceMethod string, args interface{}, reply interface{}) (err error) {
|
||||
if servicePath == "" {
|
||||
err = errors.New("servicePath no cant null")
|
||||
var (
|
||||
_client client.XClient
|
||||
)
|
||||
if _client, err = this.getclient(&ctx, clusterTag, servicePath); err != nil {
|
||||
return
|
||||
}
|
||||
var (
|
||||
spath []string
|
||||
clients map[string]client.XClient
|
||||
d *client.ConsulDiscovery
|
||||
c client.XClient
|
||||
ok bool
|
||||
)
|
||||
spath = strings.Split(servicePath, "/")
|
||||
if clients, ok = this.clusterClients[clusterTag]; !ok {
|
||||
this.clusterClients[clusterTag] = make(map[string]client.XClient)
|
||||
clients = this.clusterClients[clusterTag]
|
||||
} else {
|
||||
if c, ok = clients[spath[0]]; !ok {
|
||||
if d, err = client.NewConsulDiscovery(this.options.ServiceTag, spath[0], this.options.ConsulServers, nil); err != nil {
|
||||
return
|
||||
}
|
||||
c = client.NewBidirectionalXClient(spath[0], client.Failfast, client.RandomSelect, d, client.DefaultOption, this.msgChan)
|
||||
c.GetPlugins().Add(this)
|
||||
if this.options.RpcxStartType == RpcxStartByClient && this.options.AutoConnect {
|
||||
c.SetSelector(newSelector(this.UpdateServer))
|
||||
} else {
|
||||
c.SetSelector(newSelector(nil))
|
||||
}
|
||||
clients[spath[0]] = c
|
||||
}
|
||||
}
|
||||
ctx = context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{
|
||||
ServiceClusterTag: this.options.ServiceTag,
|
||||
CallRoutRulesKey: servicePath,
|
||||
ServiceAddrKey: "tcp@" + this.options.ServiceAddr,
|
||||
ServiceMetaKey: this.metadata,
|
||||
})
|
||||
err = c.Broadcast(ctx, serviceMethod, args, reply)
|
||||
return
|
||||
return _client.Broadcast(ctx, serviceMethod, args, reply)
|
||||
}
|
||||
|
||||
func (this *Client) ClusterBroadcast(ctx context.Context, servicePath string, serviceMethod string, args interface{}, reply interface{}) (err error) {
|
||||
@ -442,7 +265,7 @@ func (this *Client) ClientConnected(conn net.Conn) (net.Conn, error) {
|
||||
this.connectMapMu.Lock()
|
||||
delete(this.connecting, addr)
|
||||
this.connectMapMu.Unlock()
|
||||
this.Errorf("ClientConnected addr:%v", addr)
|
||||
this.Debugf("ClientConnected addr:%v", addr)
|
||||
return conn, nil
|
||||
}
|
||||
|
||||
@ -452,6 +275,7 @@ func (this *Client) ClientConnectionClose(conn net.Conn) error {
|
||||
this.connsMapMu.Lock()
|
||||
delete(this.conns, addr)
|
||||
this.connsMapMu.Unlock()
|
||||
this.Debugf("ClientConnectionClose addr:%v", addr)
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -496,6 +320,46 @@ func (this *Client) Fatalf(format string, a ...interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
//获取目标客户端
|
||||
func (this *Client) getclient(ctx *context.Context, clusterTag string, servicePath string) (c client.XClient, err error) {
|
||||
if servicePath == "" {
|
||||
err = errors.New("servicePath no cant null")
|
||||
return
|
||||
}
|
||||
var (
|
||||
spath []string
|
||||
clients map[string]client.XClient
|
||||
d *client.ConsulDiscovery
|
||||
ok bool
|
||||
)
|
||||
spath = strings.Split(servicePath, "/")
|
||||
if clients, ok = this.clusterClients[clusterTag]; !ok {
|
||||
this.clusterClients[clusterTag] = make(map[string]client.XClient)
|
||||
clients = this.clusterClients[clusterTag]
|
||||
}
|
||||
|
||||
if c, ok = clients[spath[0]]; !ok {
|
||||
if d, err = client.NewConsulDiscovery(this.options.ServiceTag, spath[0], this.options.ConsulServers, nil); err != nil {
|
||||
return
|
||||
}
|
||||
c = client.NewBidirectionalXClient(spath[0], client.Failfast, client.RandomSelect, d, client.DefaultOption, this.msgChan)
|
||||
c.GetPlugins().Add(this)
|
||||
if this.options.RpcxStartType == RpcxStartByClient && this.options.AutoConnect {
|
||||
c.SetSelector(newSelector(this.UpdateServer))
|
||||
} else {
|
||||
c.SetSelector(newSelector(nil))
|
||||
}
|
||||
clients[spath[0]] = c
|
||||
}
|
||||
*ctx = context.WithValue(*ctx, share.ReqMetaDataKey, map[string]string{
|
||||
ServiceClusterTag: this.options.ServiceTag,
|
||||
CallRoutRulesKey: servicePath,
|
||||
ServiceAddrKey: "tcp@" + this.options.ServiceAddr,
|
||||
ServiceMetaKey: this.metadata,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
//注册服务方法
|
||||
func (this *Client) registerFunction(servicePath string, fn interface{}, name string, useName bool) (string, error) {
|
||||
this.serviceMapMu.Lock()
|
||||
|
@ -29,7 +29,7 @@ func (this *apiComp) ChanageChannel(session comm.IUserSession, req *pb.ChatChana
|
||||
return
|
||||
}
|
||||
this.module.modelChat.ChanageUserExpand(session.GetUserId(), map[string]interface{}{
|
||||
"Chatchannel": req.ChannelId,
|
||||
"chatchannel": req.ChannelId,
|
||||
})
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), "chanagechannel", &pb.ChatChanageChannelResp{ChannelId: req.ChannelId, IsSucc: ok})
|
||||
|
@ -24,8 +24,8 @@ func (this *apiComp) CrossChannel(session comm.IUserSession, req *pb.ChatCrossCh
|
||||
return
|
||||
}
|
||||
this.module.modelChat.ChanageUserExpand(session.GetUserId(), map[string]interface{}{
|
||||
"catchannel": channel,
|
||||
"chatchannel": channel,
|
||||
})
|
||||
session.SendMsg(string(this.module.GetType()), "getlist", &pb.ChatCrossChannelResp{ChannelId: channel})
|
||||
session.SendMsg(string(this.module.GetType()), "crosschannel", &pb.ChatCrossChannelResp{ChannelId: channel})
|
||||
return
|
||||
}
|
||||
|
@ -19,10 +19,19 @@ func (this *apiComp) SendCheck(session comm.IUserSession, req *pb.ChatSendReq) (
|
||||
///消息发送请求
|
||||
func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (code pb.ErrorCode, data proto.Message) {
|
||||
var (
|
||||
err error
|
||||
msg *pb.DBChat
|
||||
user *pb.DBUser
|
||||
err error
|
||||
max int32
|
||||
msg *pb.DBChat
|
||||
user *pb.DBUser
|
||||
max_chat int32
|
||||
)
|
||||
|
||||
if user = this.module.ModuleUser.GetUser(session.GetUserId()); user == nil {
|
||||
this.module.Errorf("GetUser is nill")
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
|
||||
msg = &pb.DBChat{
|
||||
Id: primitive.NewObjectID().Hex(),
|
||||
Channel: req.Channel,
|
||||
@ -31,9 +40,17 @@ func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (code
|
||||
Content: req.Content,
|
||||
Ctime: time.Now().Unix(),
|
||||
}
|
||||
if max, err = this.module.configure.GetChannelRecordMax(); err != nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
}
|
||||
if max_chat, err = this.module.configure.GetChannelRecordMax(); err != nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
}
|
||||
switch msg.Channel {
|
||||
case pb.ChatChannel_World:
|
||||
if err = this.module.modelChat.addChatMsg(worldchatkey, this.module.configure.GetChannelRecordMax(), msg); err != nil {
|
||||
if err = this.module.modelChat.addChatMsg(worldchatkey, max, msg); err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
@ -41,7 +58,7 @@ func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (code
|
||||
break
|
||||
case pb.ChatChannel_Union:
|
||||
msg.UnionId = req.TargetId
|
||||
if err = this.module.modelChat.addChatMsg(fmt.Sprintf("%s:%s", unionchatkey, req.TargetId), this.module.configure.GetChannelRecordMax(), msg); err != nil {
|
||||
if err = this.module.modelChat.addChatMsg(fmt.Sprintf("%s:%s", unionchatkey, req.TargetId), max_chat, msg); err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ func (this *apiComp) SpanGetList(session comm.IUserSession, req *pb.ChatSpanGetL
|
||||
err error
|
||||
result *pb.DBUserExpand
|
||||
list []*pb.DBChat
|
||||
group int32
|
||||
)
|
||||
if result, err = this.module.modelChat.GetUserExpand(session.GetUserId()); err != nil {
|
||||
this.module.Errorf("err:%v", err)
|
||||
@ -28,7 +29,10 @@ func (this *apiComp) SpanGetList(session comm.IUserSession, req *pb.ChatSpanGetL
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
return
|
||||
}
|
||||
group := this.module.configure.GetServiecTagGroup(session.GetServiecTag())
|
||||
if group, err = this.module.configure.GetServiecTagGroup(session.GetServiecTag()); err != nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
}
|
||||
switch req.Channel {
|
||||
case pb.ChatChannel_CrossServer:
|
||||
if list, err = this.module.modelChat.GetChatQueue(req.Channel, 0, group, req.ChannelId); err != nil {
|
||||
@ -43,6 +47,6 @@ func (this *apiComp) SpanGetList(session comm.IUserSession, req *pb.ChatSpanGetL
|
||||
}
|
||||
break
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), "getlist", &pb.ChatSpanGetListResp{Chats: list})
|
||||
session.SendMsg(string(this.module.GetType()), "spangetlist", &pb.ChatSpanGetListResp{Chats: list})
|
||||
return
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ func (this *apiComp) SpanSend(session comm.IUserSession, req *pb.ChatSpanSendReq
|
||||
msg *pb.DBChat
|
||||
user *pb.DBUser
|
||||
userexpand *pb.DBUserExpand
|
||||
group int32
|
||||
max_chat int32
|
||||
)
|
||||
if userexpand, err = this.module.modelChat.GetUserExpand(session.GetUserId()); err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
@ -37,16 +39,22 @@ func (this *apiComp) SpanSend(session comm.IUserSession, req *pb.ChatSpanSendReq
|
||||
Content: req.Content,
|
||||
Ctime: time.Now().Unix(),
|
||||
}
|
||||
group := this.module.configure.GetServiecTagGroup(session.GetServiecTag())
|
||||
if group, err = this.module.configure.GetServiecTagGroup(session.GetServiecTag()); err != nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
}
|
||||
if max_chat, err = this.module.configure.GetChannelRecordMax(); err != nil {
|
||||
return
|
||||
}
|
||||
switch msg.Channel {
|
||||
case pb.ChatChannel_CrossServer:
|
||||
if err = this.module.modelChat.addChatMsg(fmt.Sprintf("%s:%d--%d", crosschatkey, group, userexpand.Chatchannel), this.module.configure.GetChannelRecordMax(), msg); err != nil {
|
||||
if err = this.module.modelChat.addChatMsg(fmt.Sprintf("%s:%d--%d", crosschatkey, group, userexpand.Chatchannel), max_chat, msg); err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
this.module.PushToUsers(group, userexpand.Chatchannel, msg)
|
||||
break
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), "send", &pb.ChatSendResp{})
|
||||
session.SendMsg(string(this.module.GetType()), "spansend", &pb.ChatSendResp{})
|
||||
return
|
||||
}
|
||||
|
@ -1,43 +1,126 @@
|
||||
package chat
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go_dreamfactory/modules"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
|
||||
"go_dreamfactory/lego/core"
|
||||
)
|
||||
|
||||
const (
|
||||
game_equipment = "game_equipment.json"
|
||||
game_chatchannel = "game_chatchannel.json"
|
||||
game_chatsystem = "game_chatsystem.json"
|
||||
game_chatservergroup = "game_chatservergroup.json"
|
||||
game_chatchannelcom = "game_chatchannelcom.json"
|
||||
)
|
||||
|
||||
///背包配置管理组件
|
||||
type configureComp struct {
|
||||
modules.MCompConfigure
|
||||
module *Chat
|
||||
}
|
||||
|
||||
//组件初始化接口
|
||||
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
this.ModuleCompBase.Init(service, module, comp, options)
|
||||
|
||||
this.module = module.(*Chat)
|
||||
this.LoadConfigure(game_chatchannel, cfg.NewGame_chatChannel)
|
||||
this.LoadConfigure(game_chatsystem, cfg.NewGame_chatSystem)
|
||||
this.LoadConfigure(game_chatservergroup, cfg.NewGame_chatServerGroup)
|
||||
this.LoadConfigure(game_chatchannelcom, cfg.NewGame_chatChannelCom)
|
||||
return
|
||||
}
|
||||
|
||||
//获取服务区 分组
|
||||
func (this *configureComp) GetServiecTagGroup(stag string) int32 {
|
||||
return 0
|
||||
func (this *configureComp) GetServiecTagGroup(stag string) (group int32, err error) {
|
||||
var (
|
||||
v interface{}
|
||||
configure *cfg.Game_chatServerGroupData
|
||||
ok bool
|
||||
)
|
||||
if v, err = this.GetConfigure(game_chatservergroup); err != nil {
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
} else {
|
||||
if configure, ok = v.(*cfg.Game_chatServerGroup).GetDataMap()[stag]; !ok {
|
||||
err = fmt.Errorf("cfg.Game_chatServerGroupData on found %v", stag)
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
group = configure.Group
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//获取自动加入频道 任务限制
|
||||
func (this *configureComp) GetAutoIntoChannelMax() int {
|
||||
return 0
|
||||
func (this *configureComp) GetAutoIntoChannelMax() (max int32, err error) {
|
||||
var (
|
||||
v interface{}
|
||||
configure *cfg.Game_chatChannelComData
|
||||
ok bool
|
||||
)
|
||||
if v, err = this.GetConfigure(game_chatchannelcom); err != nil {
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
} else {
|
||||
if configure, ok = v.(*cfg.Game_chatChannelCom).GetDataMap()["channel_allocation_max"]; !ok {
|
||||
err = fmt.Errorf("cfg.Game_chatServerGroupData on found channel_allocation_max")
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
max = configure.Value
|
||||
if max <= 0 {
|
||||
err = fmt.Errorf("cfg.Game_chatChannelComData channel_allocation_max:%v", v)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//获取手动加入频道 任务限制
|
||||
func (this *configureComp) GetChanageChannelMax() int {
|
||||
return 0
|
||||
func (this *configureComp) GetChanageChannelMax() (max int32, err error) {
|
||||
var (
|
||||
v interface{}
|
||||
configure *cfg.Game_chatChannelComData
|
||||
ok bool
|
||||
)
|
||||
if v, err = this.GetConfigure(game_chatchannelcom); err != nil {
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
} else {
|
||||
if configure, ok = v.(*cfg.Game_chatChannelCom).GetDataMap()["channel_switching_max"]; !ok {
|
||||
err = fmt.Errorf("cfg.Game_chatServerGroupData on found channel_switching_max")
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
max = configure.Value
|
||||
if max <= 0 {
|
||||
err = fmt.Errorf("cfg.Game_chatChannelComData channel_switching_max:%v", v)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//获取手动加入频道 任务限制
|
||||
func (this *configureComp) GetChannelRecordMax() int {
|
||||
return 99
|
||||
func (this *configureComp) GetChannelRecordMax() (max int32, err error) {
|
||||
var (
|
||||
v interface{}
|
||||
configure *cfg.Game_chatChannelComData
|
||||
ok bool
|
||||
)
|
||||
if v, err = this.GetConfigure(game_chatchannelcom); err != nil {
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
} else {
|
||||
if configure, ok = v.(*cfg.Game_chatChannelCom).GetDataMap()["max_chat"]; !ok {
|
||||
err = fmt.Errorf("cfg.Game_chatServerGroupData on found max_chat")
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
max = configure.Value
|
||||
if max <= 0 {
|
||||
err = fmt.Errorf("cfg.Game_chatChannelComData max_chat:%v", v)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -65,11 +65,12 @@ func (this *modelChatComp) QueryUserMsg(uid string) (result []*pb.DBChat, err er
|
||||
//查询用户未读消息
|
||||
func (this *modelChatComp) GetChatQueue(channel pb.ChatChannel, union, group, area int32) (result []*pb.DBChat, err error) {
|
||||
var (
|
||||
key string
|
||||
cdata []map[string]string
|
||||
find bson.M
|
||||
c *mongo.Cursor
|
||||
n int
|
||||
key string
|
||||
cdata []map[string]string
|
||||
find bson.M
|
||||
c *mongo.Cursor
|
||||
n int
|
||||
max_chat int32
|
||||
)
|
||||
switch channel {
|
||||
case pb.ChatChannel_World:
|
||||
@ -99,6 +100,8 @@ func (this *modelChatComp) GetChatQueue(channel pb.ChatChannel, union, group, ar
|
||||
result[i] = chat
|
||||
}
|
||||
}
|
||||
max_chat, err = this.module.configure.GetChannelRecordMax()
|
||||
|
||||
if err == redis.RedisNil {
|
||||
//query from mgo
|
||||
if c, err = this.DB.Find(core.SqlTable(this.TableName), find); err != nil {
|
||||
@ -114,7 +117,7 @@ func (this *modelChatComp) GetChatQueue(channel pb.ChatChannel, union, group, ar
|
||||
n++
|
||||
}
|
||||
if len(result) > 0 {
|
||||
this.addChatMsg(key, this.module.configure.GetChannelRecordMax(), result...)
|
||||
this.addChatMsg(key, max_chat, result...)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -130,17 +133,25 @@ func (this *modelChatComp) AddCrossChannelMember(session comm.IUserSession) (cha
|
||||
GatewayServiceId: session.GetGatewayServiceId(),
|
||||
Ip: session.GetIP(),
|
||||
}
|
||||
channel = 0
|
||||
count := 0
|
||||
group := this.module.configure.GetServiecTagGroup(session.GetServiecTag())
|
||||
maxnum := this.module.configure.GetAutoIntoChannelMax()
|
||||
var (
|
||||
count int
|
||||
group int32
|
||||
maxnum int32
|
||||
)
|
||||
channel = 1
|
||||
if group, err = this.module.configure.GetServiecTagGroup(session.GetServiecTag()); err != nil {
|
||||
return
|
||||
}
|
||||
if maxnum, err = this.module.configure.GetAutoIntoChannelMax(); err != nil {
|
||||
return
|
||||
}
|
||||
for {
|
||||
key := fmt.Sprintf("%s:%d--%d-member", crosschatkey, group, channel)
|
||||
if count, err = this.Redis.Hlen(key); err != nil {
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
if count < maxnum {
|
||||
if int32(count) < maxnum {
|
||||
if err = this.Redis.HMSet(key, map[string]interface{}{session.GetUserId(): udata}); err != nil {
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
@ -161,15 +172,23 @@ func (this *modelChatComp) ChanageChannel(session comm.IUserSession, channel int
|
||||
GatewayServiceId: session.GetGatewayServiceId(),
|
||||
Ip: session.GetIP(),
|
||||
}
|
||||
group := this.module.configure.GetServiecTagGroup(session.GetServiecTag())
|
||||
var (
|
||||
group int32
|
||||
maxnum int32
|
||||
)
|
||||
if group, err = this.module.configure.GetServiecTagGroup(session.GetServiecTag()); err != nil {
|
||||
return
|
||||
}
|
||||
key := fmt.Sprintf("%s:%d--%d-member", crosschatkey, group, channel)
|
||||
count := 0
|
||||
maxnum := this.module.configure.GetChanageChannelMax()
|
||||
if maxnum, err = this.module.configure.GetChanageChannelMax(); err != nil {
|
||||
return
|
||||
}
|
||||
if count, err = this.Redis.Hlen(key); err != nil {
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
if count < maxnum {
|
||||
if int32(count) < maxnum {
|
||||
if err = this.Redis.HMSet(key, map[string]interface{}{session.GetUserId(): udata}); err != nil {
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
@ -199,7 +218,10 @@ func (this *modelChatComp) RemoveCrossChannelMember(session comm.IUserSession) (
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
group := this.module.configure.GetServiecTagGroup(session.GetServiecTag())
|
||||
var group int32
|
||||
if group, err = this.module.configure.GetServiecTagGroup(session.GetServiecTag()); err != nil {
|
||||
return
|
||||
}
|
||||
key := fmt.Sprintf("%s:%d--%d-member", crosschatkey, group, result.Chatchannel)
|
||||
if err = this.Redis.HDel(key, session.GetUserId()); err != nil {
|
||||
this.module.Errorf("err:%v", err)
|
||||
@ -216,7 +238,7 @@ func (this *modelChatComp) SaveUserMsg(msg *pb.DBChat) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (this *modelChatComp) addChatMsg(key string, count int, msgs ...*pb.DBChat) (err error) {
|
||||
func (this *modelChatComp) addChatMsg(key string, count int32, msgs ...*pb.DBChat) (err error) {
|
||||
var (
|
||||
tempdata map[string]string
|
||||
outkey []string
|
||||
|
@ -59,7 +59,7 @@ func (this *Chat) OnInstallComp() {
|
||||
//Event------------------------------------------------------------------------------------------------------------
|
||||
func (this *Chat) EventUserOffline(session comm.IUserSession) {
|
||||
err := this.modelChat.RemoveCrossChannelMember(session)
|
||||
this.Debugf("EventUserOffline:%s err:%v", session.GetUserId(), err)
|
||||
this.Debugf("EventUserOffline:%s err:%v", session, err)
|
||||
}
|
||||
|
||||
//Push--------------------------------------------------------------------------------------------------------------
|
||||
|
@ -502,7 +502,8 @@ func (this *MCompModel) GetUserExpand(uid string) (result *pb.DBUserExpand, err
|
||||
|
||||
//修改用户扩展数据
|
||||
func (this *MCompModel) ChanageUserExpand(uid string, value map[string]interface{}) (err error) {
|
||||
if err = this.Redis.HSet("userexpand", uid, value); err != nil && err != redis.RedisNil {
|
||||
key := fmt.Sprintf("userexpand:%s", uid)
|
||||
if err = this.Redis.HMSet(key, value); err != nil && err != redis.RedisNil {
|
||||
return
|
||||
}
|
||||
err = this.UpdateModelLogs("userexpand", uid, bson.M{"uid": uid}, value)
|
||||
@ -583,7 +584,7 @@ func (this *MCompModel) Batchgetqueues(key string) (result []map[string]string,
|
||||
}
|
||||
|
||||
//批量写入队列 并返回移除队列
|
||||
func (this *MCompModel) Batchsetqueues(key string, count int, ks []string, vs []map[string]string) (outkey []string, err error) {
|
||||
func (this *MCompModel) Batchsetqueues(key string, count int32, ks []string, vs []map[string]string) (outkey []string, err error) {
|
||||
var (
|
||||
n int
|
||||
keys []string
|
||||
|
@ -6,7 +6,6 @@ import (
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -19,11 +18,13 @@ const (
|
||||
///背包配置管理组件
|
||||
type configureComp struct {
|
||||
modules.MCompConfigure
|
||||
module *Equipment
|
||||
}
|
||||
|
||||
//组件初始化接口
|
||||
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
this.ModuleCompBase.Init(service, module, comp, options)
|
||||
this.module = module.(*Equipment)
|
||||
this.LoadConfigure(game_equip, cfg.NewGame_equip)
|
||||
this.LoadConfigure(equip_attrlibrary, cfg.NewGame_equipAttrlibrary)
|
||||
this.LoadConfigure(equip_intensify, cfg.NewGame_equipIntensify)
|
||||
@ -38,12 +39,12 @@ func (this *configureComp) GetEquipmentConfigure() (configure *cfg.Game_equip, e
|
||||
ok bool
|
||||
)
|
||||
if v, err = this.GetConfigure(game_equip); err != nil {
|
||||
log.Errorf("err:%v", err)
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
} else {
|
||||
if configure, ok = v.(*cfg.Game_equip); !ok {
|
||||
err = fmt.Errorf("%T no is *cfg.Game_equipment", v)
|
||||
log.Errorf("err:%v", err)
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -57,12 +58,12 @@ func (this *configureComp) GetEquipmentConfigureById(equipmentId int32) (configu
|
||||
ok bool
|
||||
)
|
||||
if v, err = this.GetConfigure(game_equip); err != nil {
|
||||
log.Errorf("err:%v", err)
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
} else {
|
||||
if configure, ok = v.(*cfg.Game_equip).GetDataMap()[equipmentId]; !ok {
|
||||
err = fmt.Errorf("EquipmentConfigure not found:%d ", equipmentId)
|
||||
log.Errorf("err:%v", err)
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -76,12 +77,12 @@ func (this *configureComp) GetEquipmentAttrlibraryConfigure() (configure *cfg.Ga
|
||||
ok bool
|
||||
)
|
||||
if v, err = this.GetConfigure(equip_attrlibrary); err != nil {
|
||||
log.Errorf("err:%v", err)
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
} else {
|
||||
if configure, ok = v.(*cfg.Game_equipAttrlibrary); !ok {
|
||||
err = fmt.Errorf("%T no is *cfg.Game_equipment", v)
|
||||
log.Errorf("err:%v", err)
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -95,12 +96,12 @@ func (this *configureComp) GetEquipmentAttrlibraryConfigureByKey(key int32) (con
|
||||
ok bool
|
||||
)
|
||||
if v, err = this.GetConfigure(equip_attrlibrary); err != nil {
|
||||
log.Errorf("err:%v", err)
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
} else {
|
||||
if configure, ok = v.(*cfg.Game_equipAttrlibrary).GetDataMap()[key]; !ok {
|
||||
err = fmt.Errorf("EquipmentConfigure GetEquipmentAttrlibraryConfigureByKey not found:%d ", key)
|
||||
log.Errorf("err:%v", err)
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -113,7 +114,7 @@ func (this *configureComp) GetEquipmentAttrlibraryConfigureById(Id int32) (confi
|
||||
v interface{}
|
||||
)
|
||||
if v, err = this.GetConfigure(equip_attrlibrary); err != nil {
|
||||
log.Errorf("err:%v", err)
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
} else {
|
||||
configure = make([]*cfg.Game_equipAttrlibraryData, 0)
|
||||
@ -133,12 +134,12 @@ func (this *configureComp) GetEquipmentIntensifyConfigure() (configure *cfg.Game
|
||||
ok bool
|
||||
)
|
||||
if v, err = this.GetConfigure(equip_intensify); err != nil {
|
||||
log.Errorf("err:%v", err)
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
} else {
|
||||
if configure, ok = v.(*cfg.Game_equipIntensify); !ok {
|
||||
err = fmt.Errorf("%T no is *cfg.Game_equipment", v)
|
||||
log.Errorf("err:%v", err)
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -152,12 +153,12 @@ func (this *configureComp) GetEquipmentIntensifyConfigureById(Id int32) (configu
|
||||
ok bool
|
||||
)
|
||||
if v, err = this.GetConfigure(equip_intensify); err != nil {
|
||||
log.Errorf("err:%v", err)
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
} else {
|
||||
if configure, ok = v.(*cfg.Game_equipIntensify).GetDataMap()[Id]; !ok {
|
||||
err = fmt.Errorf("EquipmentConfigure not found:%d ", Id)
|
||||
log.Errorf("err:%v", err)
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -215,14 +215,23 @@ func (this *Agent) Close() {
|
||||
//分发用户消息
|
||||
func (this *Agent) messageDistribution(msg *pb.UserMessage) (err error) {
|
||||
var (
|
||||
req *pb.AgentMessage
|
||||
reply *pb.RPCMessageReply = &pb.RPCMessageReply{}
|
||||
serviceTag string = ""
|
||||
servicePath string = comm.Service_Worker
|
||||
rule string
|
||||
ok bool
|
||||
)
|
||||
|
||||
this.gateway.Debugf("agent:%s uId:%s MessageDistribution msg:%s.%s", this.sessionId, this.uId, msg.MainType, msg.SubType)
|
||||
req = &pb.AgentMessage{
|
||||
Ip: this.IP(),
|
||||
UserSessionId: this.sessionId,
|
||||
UserId: this.uId,
|
||||
ServiceTag: this.gateway.Service().GetTag(),
|
||||
GatewayServiceId: this.gateway.Service().GetId(),
|
||||
MainType: msg.MainType,
|
||||
SubType: msg.SubType,
|
||||
Message: msg.Data,
|
||||
}
|
||||
if rule, ok = this.gateway.GetMsgDistribute(msg.MainType, msg.SubType); ok {
|
||||
paths := strings.Split(rule, "/")
|
||||
if len(paths) == 3 {
|
||||
@ -239,36 +248,21 @@ func (this *Agent) messageDistribution(msg *pb.UserMessage) (err error) {
|
||||
servicePath = fmt.Sprintf("%s/%s", comm.Service_Worker, this.wId)
|
||||
}
|
||||
}
|
||||
|
||||
stime := time.Now()
|
||||
this.gateway.Debugf("agent:%s uId:%s MessageDistribution req:%v", this.sessionId, this.uId, req)
|
||||
if len(serviceTag) == 0 {
|
||||
if err = this.gateway.Service().RpcCall(context.Background(), servicePath, string(comm.Rpc_GatewayRoute), &pb.AgentMessage{
|
||||
Ip: this.IP(),
|
||||
UserSessionId: this.sessionId,
|
||||
UserId: this.uId,
|
||||
GatewayServiceId: this.gateway.Service().GetId(),
|
||||
MainType: msg.MainType,
|
||||
SubType: msg.SubType,
|
||||
Message: msg.Data,
|
||||
}, reply); err != nil {
|
||||
if err = this.gateway.Service().RpcCall(context.Background(), servicePath, string(comm.Rpc_GatewayRoute), req, reply); err != nil {
|
||||
this.gateway.Errorf("agent:%s uId:%s MessageDistribution err:%v", this.sessionId, this.uId, err)
|
||||
return
|
||||
}
|
||||
} else { //跨集群调用
|
||||
if err = this.gateway.Service().AcrossClusterRpcCall(context.Background(), serviceTag, servicePath, string(comm.Rpc_GatewayRoute), &pb.AgentMessage{
|
||||
Ip: this.IP(),
|
||||
UserSessionId: this.sessionId,
|
||||
UserId: this.uId,
|
||||
GatewayServiceId: this.gateway.Service().GetId(),
|
||||
MainType: msg.MainType,
|
||||
SubType: msg.SubType,
|
||||
Message: msg.Data,
|
||||
}, reply); err != nil {
|
||||
if err = this.gateway.Service().AcrossClusterRpcCall(context.Background(), serviceTag, servicePath, string(comm.Rpc_GatewayRoute), req, reply); err != nil {
|
||||
this.gateway.Errorf("agent:%s uId:%s MessageDistribution err:%v", this.sessionId, this.uId, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
this.gateway.Debugf("agent:%s uId:%s MessageDistribution t:%v reply:%v", this.sessionId, this.uId, time.Since(stime), reply)
|
||||
if reply.Code != pb.ErrorCode_Success {
|
||||
|
||||
data, _ := anypb.New(&pb.NotifyErrorNotifyPush{
|
||||
ReqMainType: msg.MainType,
|
||||
ReqSubType: msg.SubType,
|
||||
|
@ -43,15 +43,21 @@ func (this *AgentMgrComp) DisConnect(a IAgent) {
|
||||
if a.UserId() != "" { //登录用户 通知业务服务处理玩家离线相关
|
||||
reply := &pb.RPCMessageReply{}
|
||||
if _, err := this.service.RpcGo(context.Background(), fmt.Sprintf("%s/%s", comm.Service_Worker, a.WorkerId()), string(comm.Rpc_NoticeUserClose), &pb.NoticeUserCloseReq{
|
||||
UserSessionId: a.SessionId(),
|
||||
UserId: a.UserId(),
|
||||
Ip: a.IP(),
|
||||
ServiceTag: this.service.GetTag(),
|
||||
GatewayServiceId: this.service.GetId(),
|
||||
UserSessionId: a.SessionId(),
|
||||
UserId: a.UserId(),
|
||||
}, reply); err != nil {
|
||||
log.Errorf("uId:%s Rpc_NoticeUserClose err:%v", a.UserId(), err)
|
||||
}
|
||||
//推送跨服集群处理
|
||||
if _, err := this.service.AcrossClusterRpcGo(context.Background(), this.options.SpanServiceTag, comm.Service_Worker, string(comm.Rpc_NoticeUserClose), &pb.NoticeUserCloseReq{
|
||||
UserSessionId: a.SessionId(),
|
||||
UserId: a.UserId(),
|
||||
Ip: a.IP(),
|
||||
ServiceTag: this.service.GetTag(),
|
||||
GatewayServiceId: this.service.GetId(),
|
||||
UserSessionId: a.SessionId(),
|
||||
UserId: a.UserId(),
|
||||
}, reply); err != nil {
|
||||
log.Errorf("uId:%s Rpc_NoticeUserClose err:%v", a.UserId(), err)
|
||||
}
|
||||
|
@ -72,6 +72,7 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (cod
|
||||
//bind user
|
||||
err = session.Bind(user.Uid, this.service.GetId())
|
||||
if err != nil {
|
||||
this.module.Errorf("err:%v", err)
|
||||
code = pb.ErrorCode_BindUser
|
||||
return
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@ -113,15 +112,15 @@ func (this *SCompGateRoute) RegisterRoute(methodName string, comp reflect.Value,
|
||||
//Rpc_GatewayRoute服务接口的接收函数
|
||||
func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessage, reply *pb.RPCMessageReply) (err error) {
|
||||
method := fmt.Sprintf("%s.%s", args.MainType, args.SubType)
|
||||
defer func() { //程序异常 收集异常信息传递给前端显示
|
||||
if r := recover(); r != nil {
|
||||
buf := make([]byte, 4096)
|
||||
l := runtime.Stack(buf, false)
|
||||
reply.Code = pb.ErrorCode_Exception
|
||||
reply.ErrorMessage = fmt.Sprintf("%v: %s", r, buf[:l])
|
||||
log.Errorf("[Handle Api] m:%s reply:%s", method, reply)
|
||||
}
|
||||
}()
|
||||
// defer func() { //程序异常 收集异常信息传递给前端显示
|
||||
// if r := recover(); r != nil {
|
||||
// buf := make([]byte, 4096)
|
||||
// l := runtime.Stack(buf, false)
|
||||
// reply.Code = pb.ErrorCode_Exception
|
||||
// reply.ErrorMessage = fmt.Sprintf("%v: %s", r, buf[:l])
|
||||
// log.Errorf("[Handle Api] m:%s reply:%s", method, reply)
|
||||
// }
|
||||
// }()
|
||||
//获取用户消息处理函数
|
||||
this.mrlock.RLock()
|
||||
msghandle, ok := this.msghandles[method]
|
||||
|
42
sys/configure/structs/game.chatChannel.go
Normal file
42
sys/configure/structs/game.chatChannel.go
Normal file
@ -0,0 +1,42 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
package cfg
|
||||
|
||||
type Game_chatChannel struct {
|
||||
_dataMap map[string]*Game_chatChannelData
|
||||
_dataList []*Game_chatChannelData
|
||||
}
|
||||
|
||||
func NewGame_chatChannel(_buf []map[string]interface{}) (*Game_chatChannel, error) {
|
||||
_dataList := make([]*Game_chatChannelData, 0, len(_buf))
|
||||
dataMap := make(map[string]*Game_chatChannelData)
|
||||
for _, _ele_ := range _buf {
|
||||
if _v, err2 := NewGame_chatChannelData(_ele_); err2 != nil {
|
||||
return nil, err2
|
||||
} else {
|
||||
_dataList = append(_dataList, _v)
|
||||
dataMap[_v.Key] = _v
|
||||
}
|
||||
}
|
||||
return &Game_chatChannel{_dataList:_dataList, _dataMap:dataMap}, nil
|
||||
}
|
||||
|
||||
func (table *Game_chatChannel) GetDataMap() map[string]*Game_chatChannelData {
|
||||
return table._dataMap
|
||||
}
|
||||
|
||||
func (table *Game_chatChannel) GetDataList() []*Game_chatChannelData {
|
||||
return table._dataList
|
||||
}
|
||||
|
||||
func (table *Game_chatChannel) Get(key string) *Game_chatChannelData {
|
||||
return table._dataMap[key]
|
||||
}
|
||||
|
||||
|
42
sys/configure/structs/game.chatChannelCom.go
Normal file
42
sys/configure/structs/game.chatChannelCom.go
Normal file
@ -0,0 +1,42 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
package cfg
|
||||
|
||||
type Game_chatChannelCom struct {
|
||||
_dataMap map[string]*Game_chatChannelComData
|
||||
_dataList []*Game_chatChannelComData
|
||||
}
|
||||
|
||||
func NewGame_chatChannelCom(_buf []map[string]interface{}) (*Game_chatChannelCom, error) {
|
||||
_dataList := make([]*Game_chatChannelComData, 0, len(_buf))
|
||||
dataMap := make(map[string]*Game_chatChannelComData)
|
||||
for _, _ele_ := range _buf {
|
||||
if _v, err2 := NewGame_chatChannelComData(_ele_); err2 != nil {
|
||||
return nil, err2
|
||||
} else {
|
||||
_dataList = append(_dataList, _v)
|
||||
dataMap[_v.Key] = _v
|
||||
}
|
||||
}
|
||||
return &Game_chatChannelCom{_dataList:_dataList, _dataMap:dataMap}, nil
|
||||
}
|
||||
|
||||
func (table *Game_chatChannelCom) GetDataMap() map[string]*Game_chatChannelComData {
|
||||
return table._dataMap
|
||||
}
|
||||
|
||||
func (table *Game_chatChannelCom) GetDataList() []*Game_chatChannelComData {
|
||||
return table._dataList
|
||||
}
|
||||
|
||||
func (table *Game_chatChannelCom) Get(key string) *Game_chatChannelComData {
|
||||
return table._dataMap[key]
|
||||
}
|
||||
|
||||
|
29
sys/configure/structs/game.chatChannelComData.go
Normal file
29
sys/configure/structs/game.chatChannelComData.go
Normal file
@ -0,0 +1,29 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
package cfg
|
||||
|
||||
import "errors"
|
||||
|
||||
type Game_chatChannelComData struct {
|
||||
Key string
|
||||
Value int32
|
||||
Dec string
|
||||
}
|
||||
|
||||
func (Game_chatChannelComData) GetTypeId() int {
|
||||
return 1284108092
|
||||
}
|
||||
|
||||
func NewGame_chatChannelComData(_buf map[string]interface{}) (_v *Game_chatChannelComData, err error) {
|
||||
_v = &Game_chatChannelComData{}
|
||||
{ var _ok_ bool; if _v.Key, _ok_ = _buf["key"].(string); !_ok_ { err = errors.New("key error"); return } }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["value"].(float64); !_ok_ { err = errors.New("value error"); return }; _v.Value = int32(_tempNum_) }
|
||||
{ var _ok_ bool; if _v.Dec, _ok_ = _buf["dec"].(string); !_ok_ { err = errors.New("dec error"); return } }
|
||||
return
|
||||
}
|
29
sys/configure/structs/game.chatChannelData.go
Normal file
29
sys/configure/structs/game.chatChannelData.go
Normal file
@ -0,0 +1,29 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
package cfg
|
||||
|
||||
import "errors"
|
||||
|
||||
type Game_chatChannelData struct {
|
||||
Key string
|
||||
TagList int32
|
||||
SpeakCd int32
|
||||
}
|
||||
|
||||
func (Game_chatChannelData) GetTypeId() int {
|
||||
return -19547431
|
||||
}
|
||||
|
||||
func NewGame_chatChannelData(_buf map[string]interface{}) (_v *Game_chatChannelData, err error) {
|
||||
_v = &Game_chatChannelData{}
|
||||
{ var _ok_ bool; if _v.Key, _ok_ = _buf["key"].(string); !_ok_ { err = errors.New("key error"); return } }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["tag_list"].(float64); !_ok_ { err = errors.New("tag_list error"); return }; _v.TagList = int32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["speak_cd"].(float64); !_ok_ { err = errors.New("speak_cd error"); return }; _v.SpeakCd = int32(_tempNum_) }
|
||||
return
|
||||
}
|
42
sys/configure/structs/game.chatServerGroup.go
Normal file
42
sys/configure/structs/game.chatServerGroup.go
Normal file
@ -0,0 +1,42 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
package cfg
|
||||
|
||||
type Game_chatServerGroup struct {
|
||||
_dataMap map[string]*Game_chatServerGroupData
|
||||
_dataList []*Game_chatServerGroupData
|
||||
}
|
||||
|
||||
func NewGame_chatServerGroup(_buf []map[string]interface{}) (*Game_chatServerGroup, error) {
|
||||
_dataList := make([]*Game_chatServerGroupData, 0, len(_buf))
|
||||
dataMap := make(map[string]*Game_chatServerGroupData)
|
||||
for _, _ele_ := range _buf {
|
||||
if _v, err2 := NewGame_chatServerGroupData(_ele_); err2 != nil {
|
||||
return nil, err2
|
||||
} else {
|
||||
_dataList = append(_dataList, _v)
|
||||
dataMap[_v.Server] = _v
|
||||
}
|
||||
}
|
||||
return &Game_chatServerGroup{_dataList:_dataList, _dataMap:dataMap}, nil
|
||||
}
|
||||
|
||||
func (table *Game_chatServerGroup) GetDataMap() map[string]*Game_chatServerGroupData {
|
||||
return table._dataMap
|
||||
}
|
||||
|
||||
func (table *Game_chatServerGroup) GetDataList() []*Game_chatServerGroupData {
|
||||
return table._dataList
|
||||
}
|
||||
|
||||
func (table *Game_chatServerGroup) Get(key string) *Game_chatServerGroupData {
|
||||
return table._dataMap[key]
|
||||
}
|
||||
|
||||
|
27
sys/configure/structs/game.chatServerGroupData.go
Normal file
27
sys/configure/structs/game.chatServerGroupData.go
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
package cfg
|
||||
|
||||
import "errors"
|
||||
|
||||
type Game_chatServerGroupData struct {
|
||||
Server string
|
||||
Group int32
|
||||
}
|
||||
|
||||
func (Game_chatServerGroupData) GetTypeId() int {
|
||||
return 825941074
|
||||
}
|
||||
|
||||
func NewGame_chatServerGroupData(_buf map[string]interface{}) (_v *Game_chatServerGroupData, err error) {
|
||||
_v = &Game_chatServerGroupData{}
|
||||
{ var _ok_ bool; if _v.Server, _ok_ = _buf["server"].(string); !_ok_ { err = errors.New("server error"); return } }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["group"].(float64); !_ok_ { err = errors.New("group error"); return }; _v.Group = int32(_tempNum_) }
|
||||
return
|
||||
}
|
42
sys/configure/structs/game.chatSystem.go
Normal file
42
sys/configure/structs/game.chatSystem.go
Normal file
@ -0,0 +1,42 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
package cfg
|
||||
|
||||
type Game_chatSystem struct {
|
||||
_dataMap map[int32]*Game_chatSystemData
|
||||
_dataList []*Game_chatSystemData
|
||||
}
|
||||
|
||||
func NewGame_chatSystem(_buf []map[string]interface{}) (*Game_chatSystem, error) {
|
||||
_dataList := make([]*Game_chatSystemData, 0, len(_buf))
|
||||
dataMap := make(map[int32]*Game_chatSystemData)
|
||||
for _, _ele_ := range _buf {
|
||||
if _v, err2 := NewGame_chatSystemData(_ele_); err2 != nil {
|
||||
return nil, err2
|
||||
} else {
|
||||
_dataList = append(_dataList, _v)
|
||||
dataMap[_v.Key] = _v
|
||||
}
|
||||
}
|
||||
return &Game_chatSystem{_dataList:_dataList, _dataMap:dataMap}, nil
|
||||
}
|
||||
|
||||
func (table *Game_chatSystem) GetDataMap() map[int32]*Game_chatSystemData {
|
||||
return table._dataMap
|
||||
}
|
||||
|
||||
func (table *Game_chatSystem) GetDataList() []*Game_chatSystemData {
|
||||
return table._dataList
|
||||
}
|
||||
|
||||
func (table *Game_chatSystem) Get(key int32) *Game_chatSystemData {
|
||||
return table._dataMap[key]
|
||||
}
|
||||
|
||||
|
54
sys/configure/structs/game.chatSystemData.go
Normal file
54
sys/configure/structs/game.chatSystemData.go
Normal file
@ -0,0 +1,54 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
package cfg
|
||||
|
||||
import "errors"
|
||||
|
||||
type Game_chatSystemData struct {
|
||||
Key int32
|
||||
Type int32
|
||||
Title string
|
||||
Close string
|
||||
Test string
|
||||
Data int32
|
||||
Week []int32
|
||||
TimeH int32
|
||||
TimeM int32
|
||||
}
|
||||
|
||||
func (Game_chatSystemData) GetTypeId() int {
|
||||
return -198348435
|
||||
}
|
||||
|
||||
func NewGame_chatSystemData(_buf map[string]interface{}) (_v *Game_chatSystemData, err error) {
|
||||
_v = &Game_chatSystemData{}
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["key"].(float64); !_ok_ { err = errors.New("key error"); return }; _v.Key = int32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["type"].(float64); !_ok_ { err = errors.New("type error"); return }; _v.Type = int32(_tempNum_) }
|
||||
{ var _ok_ bool; if _v.Title, _ok_ = _buf["title"].(string); !_ok_ { err = errors.New("title error"); return } }
|
||||
{ var _ok_ bool; if _v.Close, _ok_ = _buf["close"].(string); !_ok_ { err = errors.New("close error"); return } }
|
||||
{ var _ok_ bool; if _v.Test, _ok_ = _buf["test"].(string); !_ok_ { err = errors.New("test error"); return } }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["data"].(float64); !_ok_ { err = errors.New("data error"); return }; _v.Data = int32(_tempNum_) }
|
||||
{
|
||||
var _arr_ []interface{}
|
||||
var _ok_ bool
|
||||
if _arr_, _ok_ = _buf["week"].([]interface{}); !_ok_ { err = errors.New("week error"); return }
|
||||
|
||||
_v.Week = make([]int32, 0, len(_arr_))
|
||||
|
||||
for _, _e_ := range _arr_ {
|
||||
var _list_v_ int32
|
||||
{ var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = int32(_x_) }
|
||||
_v.Week = append(_v.Week, _list_v_)
|
||||
}
|
||||
}
|
||||
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["time_h"].(float64); !_ok_ { err = errors.New("time_h error"); return }; _v.TimeH = int32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["time_m"].(float64); !_ok_ { err = errors.New("time_m error"); return }; _v.TimeM = int32(_tempNum_) }
|
||||
return
|
||||
}
|
Loading…
Reference in New Issue
Block a user