内容简介:大家好,我是彬哥,本节给大家讲下LollipopGov1.0.20190102版本游戏服务器邮件功能,抛砖引玉了,主要是针对Go语言游戏服务器邮件功能处理。每天坚持学习1小时Go语言,大家加油,我是彬哥,下期见!如果文章中不同观点、意见请文章下留言或者关注下方订阅号反馈!
大家好,我是彬哥,本节给大家讲下LollipopGov1.0.20190102版本游戏服务器邮件功能,抛砖引玉了,主要是针对 Go 语言游戏服务器邮件功能处理。
邮件
//------------------------------------------------------------------------------ var EmailDatatmp map[int]*player.EmailST var ItemListtmp map[int]*player.ItemST var PaoMaDeng map[int]*player.MsgST var iicounmsg int = 3 var iicounemail int = 6 func init() { EmailDatatmp = make(map[int]*player.EmailST) ItemListtmp = make(map[int]*player.ItemST) PaoMaDeng = make(map[int]*player.MsgST) if true { data := new(player.EmailST) data.ID = 1 data.Name = "测试邮件1" data.Sender = "test1" data.Type = 1 data.Time = int(util.GetNowUnix_LollipopGo()) data.Content = "测试邮件内容1" data.IsAdd_ons = false data.IsOpen = false data.IsGet = false EmailDatatmp[data.ID] = data } if true { data := new(player.EmailST) data.ID = 2 data.Name = "测试邮件2" data.Sender = "test2" data.Type = 4 data.Time = int(util.GetNowUnix_LollipopGo()) data.Content = "测试邮件内容2" data.IsAdd_ons = false data.IsOpen = false data.IsGet = false EmailDatatmp[data.ID] = data } if true { data := new(player.EmailST) data.ID = 3 data.Name = "测试邮件3" data.Sender = "test3" data.Type = 1 data.Time = int(util.GetNowUnix_LollipopGo()) data.Content = "测试邮件内容3" data.IsAdd_ons = true data.IsOpen = false data.IsGet = false if true { dataitem := new(player.ItemST) dataitem.ID = 1 dataitem.Icon = "" dataitem.Name = "M卡" dataitem.Itype = 1 dataitem.Num = 10 ItemListtmp[dataitem.ID] = dataitem } data.ItemList = ItemListtmp EmailDatatmp[data.ID] = data } if true { data := new(player.EmailST) data.ID = 4 data.Name = "测试邮件4" data.Sender = "test4" data.Type = 4 data.Time = int(util.GetNowUnix_LollipopGo()) data.Content = "测试邮件内容1" data.IsAdd_ons = false data.IsOpen = false data.IsGet = true EmailDatatmp[data.ID] = data } if true { data := new(player.EmailST) data.ID = 5 data.Name = "测试邮件5" data.Sender = "test5" data.Type = 1 data.Time = int(util.GetNowUnix_LollipopGo()) data.Content = "测试邮件内容1" data.IsAdd_ons = false data.IsOpen = true data.IsGet = true EmailDatatmp[data.ID] = data } if true { data := new(player.EmailST) data.ID = 6 data.Name = "测试邮件6" data.Sender = "test6" data.Type = 4 data.Time = int(util.GetNowUnix_LollipopGo()) data.Content = "测试邮件内容3" data.IsAdd_ons = true data.IsOpen = true data.IsGet = true if true { dataitem := new(player.ItemST) dataitem.ID = 1 dataitem.Icon = "" dataitem.Name = "M卡" dataitem.Itype = 1 dataitem.Num = 10 ItemListtmp[dataitem.ID] = dataitem } data.ItemList = ItemListtmp EmailDatatmp[data.ID] = data } //-------------------------------------------------------------------------- // DefaultMsg map[string]*player.MsgST // 默认跑马灯消息 if true { data := new(player.MsgST) data.MsgID = 1 data.MsgType = player.MsgType1 data.MsgDesc = "系统消息:充值998,送B站24K纯金哥斯拉" PaoMaDeng[data.MsgID] = data } if true { data := new(player.MsgST) data.MsgID = 2 data.MsgType = player.MsgType2 data.MsgDesc = "恭喜【XXX玩家】在XX比赛中获得xxx奖励" PaoMaDeng[data.MsgID] = data } if true { data := new(player.MsgST) data.MsgID = 3 data.MsgType = player.MsgType3 data.MsgDesc = "恭喜【XXX玩家】在兑换中心成功兑换SSS" PaoMaDeng[data.MsgID] = data } return } func TimeMsgNotice(conn *websocket.Conn, Conndata *rpc.Client) { //return // if GL_type != "8894" { // return // } good_conn := conn for { select { case <-time.After(time.Second * 30): { data := GetEmailDataFromDB(Conndata) fmt.Println("GetEmailDataFromDB------:", data) if len(data) > 0 { iicounemail++ EmailNoticeFunc(good_conn) } // iicounmsg++ // MsgNoticeFuncbak(conn) // EmailNoticeFunc(conn) } } } } //------------------------------------------------------------------------------ // 获取数据的数据 from DB func GetEmailDataFromDB(Conndata *rpc.Client) map[int]*player.EmailST { args := 1 var reply map[int]*player.EmailST // 异步调用【结构的方法】 if Conndata != nil { divCall := Conndata.Go("Arith.GetPlayerEmailDataGM", args, &reply, nil) replyCall := <-divCall.Done _ = replyCall.Reply } else { fmt.Println("ConnRPC == nil") } return reply } func EmailNoticeFunc(conn *websocket.Conn) { EmailDatatmpbak := make(map[int]*player.EmailST) if true { data := new(player.EmailST) data.ID = iicounemail data.Name = "邮件通知" data.Sender = "admin" data.Type = 1 data.Time = int(util.GetNowUnix_LollipopGo()) data.Content = "通知内容" data.IsAdd_ons = false data.IsOpen = true data.IsGet = true EmailDatatmpbak[data.ID] = data } data_send := &Proto2.G_Broadcast_NoticePlayerEmail{ Protocol: Proto.G_GameGlobal_Proto, Protocol2: Proto2.G_Broadcast_NoticePlayerEmailProto2, EmailData: EmailDatatmpbak, } fmt.Println("邮件通知:", data_send) PlayerSendToServer(conn, data_send) return } // 全服通知 func MsgNoticeFuncbak(conn *websocket.Conn) { PaoMaDengbak := make(map[int]*player.MsgST) if true { data := new(player.MsgST) data.MsgID = iicounmsg data.MsgType = player.MsgType1 data.MsgDesc = "系统消息:充值998,送B站24K纯金哥斯拉" PaoMaDengbak[data.MsgID] = data } data_send := &Proto2.G_Broadcast_MsgNoticePlayer{ Protocol: Proto.G_GameGlobal_Proto, Protocol2: Proto2.G_Broadcast_MsgNoticePlayerProto2, OpenID: "6412121cbb2dc2cb9e460cfee7046be2", MsgData: PaoMaDengbak, } fmt.Println("消息通知:", data_send) PlayerSendToServer(conn, data_send) return } //------------------------------------------------------------------------------
每天坚持学习1小时Go语言,大家加油,我是彬哥,下期见!如果文章中不同观点、意见请文章下留言或者关注下方订阅号反馈!
社区交流群:221273219
Golang语言社区论坛 :
LollipopGo游戏服务器地址:
https://github.com/Golangltd/LollipopGo
社区视频课程课件GIT地址:
https://github.com/Golangltd/codeclassGolang语言社区
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- 开源 | Hippy:腾讯开源的跨端开发框架
- WeGeek | WePY 开源框架
- 开源 | vnpy:基于 Python 的开源量化交易平台开发框架
- 优秀开源框架的扩展机制实现
- 开源Botnet框架Byob分析
- 滴滴开源小程序框架 Mpx
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Ruby on Rails 3 Tutorial
Michael Hartl / Addison-Wesley Professional / 2010-12-16 / USD 39.99
“Ruby on Rails™ 3 Tutorial: Learn Rails by Example by Michael Hartl has become a must read for developers learning how to build Rails apps.” —Peter Cooper, Editor of Ruby Inside Using Rails ......一起来看看 《Ruby on Rails 3 Tutorial》 这本书的介绍吧!