本文整理汇总了Golang中misc/packet.Reader函数的典型用法代码示例。如果您正苦于以下问题:Golang Reader函数的具体用法?Golang Reader怎么用?Golang Reader使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Reader函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Add
func Add(Type int16, user_id int32, timeout int64, params []byte) int32 {
defer _event_err()
req := event.ADD_EVENT{}
req.F_type = Type
req.F_user_id = user_id
req.F_timeout = timeout
req.F_params = params
ret := _call(packet.Pack(event.Code["add_req"], &req, nil))
reader := packet.Reader(ret)
tbl, _ := event.PKT_INT(reader)
return tbl.F_v
}
示例2: GroupForward
//------------------------------------------------ Forward to Hub/Group
func GroupForward(req *IPCObject) bool {
defer _hub_err()
msg := hub.FORWARDIPC{F_IPC: req.Json()}
ret := _call(packet.Pack(hub.Code["forwardgroup_req"], &msg, nil))
reader := packet.Reader(ret)
tbl, err := hub.PKT_INT(reader)
if err != nil || tbl.F_v == 0 {
return false
}
return true
}
示例3: Ping
func Ping() bool {
defer _event_err()
req := event.INT{}
req.F_v = 1
ret := _call(packet.Pack(event.Code["ping_req"], &req, nil))
reader := packet.Reader(ret)
tbl, _ := event.PKT_INT(reader)
if tbl.F_v != req.F_v {
return false
}
return true
}
示例4: AddUser
func AddUser(id int32) bool {
defer _hub_err()
req := hub.ID{}
req.F_id = id
ret := _call(packet.Pack(hub.Code["adduser_req"], &req, nil))
reader := packet.Reader(ret)
tbl, err := hub.PKT_INT(reader)
if err != nil || tbl.F_v == 0 {
return false
}
return true
}
示例5: Login
func Login(id int32) bool {
defer _hub_err()
req := hub.LOGIN_REQ{}
req.F_id = id
ret := _call(packet.Pack(hub.Code["login_req"], &req, nil))
reader := packet.Reader(ret)
tbl, err := hub.PKT_LOGIN_ACK(reader)
if err != nil || !tbl.F_success {
return false
}
return true
}
示例6: Logout
func Logout(id int32) bool {
defer _hub_err()
req := protos.ID{}
req.F_id = id
ret := _call(packet.Pack(protos.Code["logout_req"], req, nil))
reader := packet.Reader(ret)
tbl, err := protos.PKT_INT(reader)
if err != nil || tbl.F_v == 0 {
return false
}
return true
}
示例7: AddUser
func AddUser(id int32) bool {
defer _hub_err()
req := ID{}
req.F_id = id
ret := _call(packet.Pack(Code["adduser_req"], &req, nil))
reader := packet.Reader(ret)
tbl, err := PKT_INT(reader)
if err != nil || tbl.F_v == 0 {
NOTICE("HUB AddUser return", false, "param", id)
return false
}
return true
}
示例8: Forward
//---------------------------------------------------------- Forward IPCObject
func Forward(req *IPCObject) bool {
defer _hub_err()
// HUB protocol forwarding
msg := FORWARDIPC{F_IPC: req.Json()}
ret := _call(packet.Pack(Code["forward_req"], &msg, nil))
reader := packet.Reader(ret)
tbl, err := PKT_INT(reader)
if err != nil || tbl.F_v == 0 {
ERR("HUB Forward return false", "param", req)
return false
}
return true
}
示例9: Logout
func Logout(id int32) bool {
defer _hub_err()
req := ID{}
req.F_id = id
ret := _call(packet.Pack(Code["logout_req"], &req, nil))
reader := packet.Reader(ret)
tbl, _ := PKT_INT(reader)
if tbl.F_v == 0 {
NOTICE("HUB Logout return ", false, "param", id)
return false
}
return true
}
示例10: Protect
func Protect(id int32, until time.Time) bool {
defer _hub_err()
req := hub.ID{}
req.F_id = id
ret := _call(packet.Pack(hub.Code["protect_req"], &req, nil))
reader := packet.Reader(ret)
tbl, err := hub.PKT_INT(reader)
if err != nil || tbl.F_v == 0 {
return false
}
return true
}
示例11: StatsAgent
//------------------------------------------------ Stats Server Agent
func StatsAgent(incoming chan []byte, conn net.Conn) {
queue_timer := make(chan int32, 1)
queue_timer <- 1
for {
select {
case sample := <-incoming:
reader := packet.Reader(sample)
HandleRequest(reader)
case <-queue_timer:
log.Println("============== STATS QUEUE SIZE:", len(incoming), "===================")
timer.Add(1, time.Now().Unix()+PRINT_INTERVAL, queue_timer)
}
}
}
示例12: Login
func Login(id int32) bool {
defer _hub_err()
req := LOGIN_REQ{}
req.F_id = id
ret := _call(packet.Pack(Code["login_req"], &req, nil))
reader := packet.Reader(ret)
tbl, _ := PKT_LOGIN_ACK(reader)
if tbl.F_success == 0 {
NOTICE("HUB Login return ", false, "param", id)
return false
}
return true
}
示例13: Protect
func Protect(id int32, until int64) bool {
defer _hub_err()
req := PROTECT{}
req.F_id = id
req.F_protecttime = until
ret := _call(packet.Pack(Code["protect_req"], &req, nil))
reader := packet.Reader(ret)
tbl, _ := PKT_INT(reader)
if tbl.F_v == 0 {
NOTICE("HUB Protect return", false, "param", id, until)
return false
}
return true
}
示例14: HubAgent
//---------------------------------------------------------- Hub processing
func HubAgent(incoming chan []byte, conn net.Conn) {
config := cfg.Get()
if config["profile"] == "true" {
helper.SetMemProfileRate(1)
defer func() {
helper.GC()
helper.DumpHeap()
helper.PrintGCSummary()
}()
}
hostid := atomic.AddInt32(&_host_genid, 1)
// forward buffer
forward := make(chan []byte, MAXCHAN)
// output buffer
output := make(chan []byte, MAXCHAN)
protos.AddServer(hostid, forward)
log.Printf("game server [id:%v] connected\n", hostid)
go _write_routine(output, conn)
defer func() {
protos.RemoveServer(hostid)
core.LogoutServer(hostid)
close(forward)
close(output)
log.Printf("game server [id:%v] disconnected\n", hostid)
}()
for {
select {
case msg, ok := <-incoming: // from hub
if !ok {
return
}
reader := packet.Reader(msg)
protos.HandleRequest(hostid, reader, output)
case msg := <-forward: // send forward packet
helper.SendChan(0, msg, output)
}
}
}
示例15: GetInfo
func GetInfo(id int32) (info Info, err error) {
defer _hub_err()
req := protos.ID{}
req.F_id = id
ret := _call(packet.Pack(protos.Code["getinfo_req"], req, nil))
reader := packet.Reader(ret)
tbl, _err := protos.PKT_INFO(reader)
info.Id = tbl.F_id
info.State = tbl.F_state
info.Score = tbl.F_score
info.Clan = tbl.F_clan
info.ProtectTime = tbl.F_protecttime
info.Name = tbl.F_name
return info, _err
}