當前位置: 首頁>>代碼示例>>Golang>>正文


Golang packet.Reader函數代碼示例

本文整理匯總了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
}
開發者ID:nkts,項目名稱:golang-devops-stuff,代碼行數:12,代碼來源:event_func.go

示例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
}
開發者ID:nkts,項目名稱:golang-devops-stuff,代碼行數:14,代碼來源:hub_func.go

示例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
}
開發者ID:nkts,項目名稱:golang-devops-stuff,代碼行數:13,代碼來源:event_func.go

示例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
}
開發者ID:nkts,項目名稱:golang-devops-stuff,代碼行數:14,代碼來源:hub_func.go

示例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
}
開發者ID:nkts,項目名稱:golang-devops-stuff,代碼行數:14,代碼來源:hub_func.go

示例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
}
開發者ID:hardPass,項目名稱:gonet,代碼行數:14,代碼來源:hub_func.go

示例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
}
開發者ID:hycxa,項目名稱:gonet,代碼行數:15,代碼來源:hub_func.go

示例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
}
開發者ID:hycxa,項目名稱:gonet,代碼行數:16,代碼來源:hub_func.go

示例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
}
開發者ID:hycxa,項目名稱:gonet,代碼行數:15,代碼來源:hub_func.go

示例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
}
開發者ID:nkts,項目名稱:golang-devops-stuff,代碼行數:15,代碼來源:hub_func.go

示例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)
		}
	}
}
開發者ID:hycxa,項目名稱:gonet,代碼行數:16,代碼來源:agent.go

示例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
}
開發者ID:hycxa,項目名稱:gonet,代碼行數:15,代碼來源:hub_func.go

示例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
}
開發者ID:hycxa,項目名稱:gonet,代碼行數:17,代碼來源:hub_func.go

示例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)
		}
	}

}
開發者ID:nkts,項目名稱:golang-devops-stuff,代碼行數:47,代碼來源:agent.go

示例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
}
開發者ID:hardPass,項目名稱:gonet,代碼行數:17,代碼來源:hub_func.go


注:本文中的misc/packet.Reader函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。