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


Golang proto.Uint32函數代碼示例

本文整理匯總了Golang中code/google/com/p/goprotobuf/proto.Uint32函數的典型用法代碼示例。如果您正苦於以下問題:Golang Uint32函數的具體用法?Golang Uint32怎麽用?Golang Uint32使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Uint32函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestFrameworkReRegisteredMessageHandling

func TestFrameworkReRegisteredMessageHandling(t *testing.T) {
	sched := NewMesosScheduler()
	sched.Reregistered = func(driver *SchedulerDriver, masterInfo *mesos.MasterInfo) {
		if masterInfo == nil {
			log.Fatalf("Scheduler.Reregistered expects masterInfo, but got nil")
		}

		if masterInfo.GetId() != "master-1" ||
			masterInfo.GetIp() != 123456 ||
			masterInfo.GetPort() != 12345 {
			log.Fatalf("Scheduler.Registered expected MasterInfo values are missing.")
		}
	}

	msg := &mesos.FrameworkReregisteredMessage{
		FrameworkId: &mesos.FrameworkID{Value: proto.String("test-framework-1")},
		MasterInfo: &mesos.MasterInfo{
			Id:   proto.String("master-1"),
			Ip:   proto.Uint32(123456),
			Port: proto.Uint32(12345),
		},
	}
	driver, err := NewSchedDriver(sched, &mesos.FrameworkInfo{}, "localhost:0")
	if err != nil {
		t.Fatal(err)
	}
	driver.schedMsgQ <- msg
}
開發者ID:kensipe,項目名稱:gomes,代碼行數:28,代碼來源:driver_test.go

示例2: UpdateFrozenUser

// Update the datastore with the user's current state.
func (server *Server) UpdateFrozenUser(client *Client, state *mumbleproto.UserState) {
	// Full sync If there's no userstate messgae provided, or if there is one, and
	// it includes a registration operation.
	user := client.user
	nanos := time.Now().Unix()
	if state == nil || state.UserId != nil {
		fu, err := user.Freeze()
		if err != nil {
			server.Fatal(err)
		}
		fu.LastActive = proto.Uint64(uint64(nanos))
		err = server.freezelog.Put(fu)
		if err != nil {
			server.Fatal(err)
		}
	} else {
		fu := &freezer.User{}
		fu.Id = proto.Uint32(user.Id)
		if state.ChannelId != nil {
			fu.LastChannelId = proto.Uint32(uint32(client.Channel.Id))
		}
		if state.TextureHash != nil {
			fu.TextureBlob = proto.String(user.TextureBlob)
		}
		if state.CommentHash != nil {
			fu.CommentBlob = proto.String(user.CommentBlob)
		}
		fu.LastActive = proto.Uint64(uint64(nanos))
		err := server.freezelog.Put(fu)
		if err != nil {
			server.Fatal(err)
		}
	}
	server.numLogOps += 1
}
開發者ID:rok-kek,項目名稱:grumble,代碼行數:36,代碼來源:freeze.go

示例3: createSubmit

func createSubmit(db *sqlx.DB, sub *scannedSubmit, submitNo int) *tickets.Ticket_Submit {
	var result tickets.Ticket_Submit
	result.SubmitNumber = proto.Uint32(uint32(submitNo))
	if sub.Arrived > 0 {
		result.Arrived = proto.Uint64(uint64(sub.Arrived))
	}
	if result.Compiled = proto.Bool(sub.Compiled == 1); !result.GetCompiled() {
		return &result
	}
	if sub.SchoolMode != 0 {
		result.School = &tickets.Ticket_Submit_School{TestsTaken: proto.Uint32(uint32(sub.Taken)), TestsPassed: proto.Uint32(uint32(sub.Passed))}
	} else {
		var description string
		var test int64
		err := db.QueryRow("select ResultDesc.Description, Results.Test from Results, ResultDesc where "+
			"Results.UID = ? and ResultDesc.ID = Results.Result and not ResultDesc.Success order by Results.Test",
			sub.TestingID).Scan(&description, &test)
		switch {
		case err == sql.ErrNoRows:
			if sub.Passed != 0 && sub.Passed == sub.Taken {
				result.Acm = &tickets.Ticket_Submit_ACM{Result: proto.String("ACCEPTED")}
			}
		case err != nil:
			log.Fatal(err)
			return nil
		default:
			result.Acm = &tickets.Ticket_Submit_ACM{Result: &description, TestId: proto.Uint32(uint32(test))}
		}
	}
	return &result
}
開發者ID:petemoore,項目名稱:printing3,代碼行數:31,代碼來源:ticket_grabber.go

示例4: MsgProjectDelete

func MsgProjectDelete(conn net.Conn, msg *message.Msg) {
	proj := &Project{
		Id: *msg.Projects.Id,
	}
	var answer *message.Msg
	temp := getListOfUser(proj.Id)
	if err := proj.Del(dbPool); err != nil {
		answer = &message.Msg{
			Target:    message.TARGET_PROJECTS.Enum(),
			Command:   message.CMD_ERROR.Enum(),
			AuthorId:  proto.Uint32(*msg.AuthorId),
			SessionId: proto.String(*msg.SessionId),
			Error: &message.Msg_Error{
				ErrorId: proto.Uint32(32),
			},
		}
	} else {
		answer = &message.Msg{
			Target:    message.TARGET_PROJECTS.Enum(),
			Command:   message.CMD_SUCCES.Enum(),
			AuthorId:  proto.Uint32(*msg.AuthorId),
			SessionId: proto.String(*msg.SessionId),
		}
		sendMsgToallUser(temp, msg)
	}
	data, err := proto.Marshal(answer)
	if err != nil {
		LOGGER.Print("Impossible to marshal msg in MsgProjectUpdate", err, answer)
		return
	}
	conn.Write(write_int32(int32(len(data))))
	conn.Write(data)
}
開發者ID:Khady,項目名稱:obiwan-kanbanobi,代碼行數:33,代碼來源:project.go

示例5: TestParseSectionIntro_Valid

func TestParseSectionIntro_Valid(t *testing.T) {
	lines := []string{
		"10",
		"BUILDID",
		"NODEID 123 321 789",
		"12 23 34",
	}
	trace := Trace{}
	err := parseSectionIntro(lines, &trace)
	if err != nil {
		t.Fatal("Unexpected error:", err)
	}
	expectedTrace := Trace{
		FileFormatVersion: proto.Int32(10),
		BuildId:           proto.String("BUILDID"),
		NodeId:            proto.String("NODEID"),
		ProcessStartTimeMicroseconds: proto.Int64(123),
		SequenceNumber:               proto.Int32(321),
		TraceCreationTimestamp:       proto.Int64(789),
		PcapReceived:                 proto.Uint32(12),
		PcapDropped:                  proto.Uint32(23),
		InterfaceDropped:             proto.Uint32(34),
	}
	checkProtosEqual(t, &expectedTrace, &trace)
}
開發者ID:sburnett,項目名稱:bismark-passive-server-go,代碼行數:25,代碼來源:trace_test.go

示例6: LeaveGroup

func (self *InterfaceForProject) LeaveGroup(interfaceCMD *business.Command) (resultPacket Packet, err error) {
	//1.從interfaceCMD 中解析出所需要的信息
	//2.處理,並且得到結果
	//3.把結果寫入CMD,並且做成Packet 返回。

	//1.解析...................................
	dialogid := interfaceCMD.GetGroupid()
	if dialogid == 0 {
		feedbackCMD.Result = proto.Uint32(2)
		feedbackCMD.ResultDescription = proto.String("no dialogid")
		resultPacket = *MakeInterfacePacket(feedbackCMD, 103)
		return resultPacket, err
	}
	//var uids []uint64
	//	uids = make([]uint64, 0, len(interfaceCMD.GetUid()))
	uids := interfaceCMD.GetUid()[:]
	if uids == nil {
		feedbackCMD.Result = proto.Uint32(2)
		feedbackCMD.ResultDescription = proto.String("no uid")
		resultPacket = *MakeInterfacePacket(feedbackCMD, 103)
		return resultPacket, err
	}
	////檢測uid,dialogid是否合法。。。未完成********************

	//2.處理...................................

	//查詢數據庫的dialog表,給對應的uid添加當前時間戳。修該chatMap的dialogId的成員。

	//1.修改數據庫dialog表,添加時間戳
	dbUpdateDialog, err := self.InterfaceDB.Db.Prepare("update dialog set timestamp=? where dialog_id=? and uid=?")

	if err != nil {
		ImBusinessLog("Prepare to update dialog error:", err)
		feedbackCMD.Result = proto.Uint32(1)
		feedbackCMD.ResultDescription = proto.String("IM error.")
		resultPacket = *MakeInterfacePacket(feedbackCMD, 103)
		return resultPacket, err
	}
	defer dbUpdateDialog.Close()
	for _, uid := range uids {
		_, err = dbUpdateDialog.Exec(time.Now().Format("2006-01-02 15:04:05"), dialogid, uid)
		if err != nil {
			ImBusinessLog("Update dialog error : ", err)
			feedbackCMD.Result = proto.Uint32(1)
			feedbackCMD.ResultDescription = proto.String("IM error.")
			resultPacket = *MakeInterfacePacket(feedbackCMD, 103)
			return resultPacket, err
		}
		//2.修改chatMap
		_, flag := SessionTable[uid]
		if flag == true {
			delete(SessionTable[uid].chatMap, dialogid)
		}
	}
	//3.打包...................................
	feedbackCMD.Result = proto.Uint32(0)
	feedbackCMD.ResultDescription = proto.String("OK")
	resultPacket = *MakeInterfacePacket(feedbackCMD, 103)
	return resultPacket, nil
}
開發者ID:HYQMartin,項目名稱:mybeeim,代碼行數:60,代碼來源:interfaceforproject.go

示例7: NewMasterInfo

func NewMasterInfo(id string, ip, port uint32) *mesos.MasterInfo {
	return &mesos.MasterInfo{
		Id:   proto.String(id),
		Ip:   proto.Uint32(ip),
		Port: proto.Uint32(port),
	}
}
開發者ID:vladimirvivien,項目名稱:gomes,代碼行數:7,代碼來源:mesosutil.go

示例8: FreezeBan

// Freeze a ban into a flattened protobuf-based struct
// ready to be persisted to disk.
func FreezeBan(ban ban.Ban) (fb *freezer.Ban) {
	fb = new(freezer.Ban)

	fb.Ip = ban.IP
	fb.Mask = proto.Uint32(uint32(ban.Mask))
	fb.Username = proto.String(ban.Username)
	fb.CertHash = proto.String(ban.CertHash)
	fb.Reason = proto.String(ban.Reason)
	fb.Start = proto.Int64(ban.Start)
	fb.Duration = proto.Uint32(ban.Duration)
	return
}
開發者ID:rok-kek,項目名稱:grumble,代碼行數:14,代碼來源:freeze.go

示例9: unidentifiedUser

func unidentifiedUser(conn net.Conn, msg *message.Msg) {
	LOGGER.Print("unidentifiedUser")
	answer := &message.Msg{
		Target:    message.TARGET_IDENT.Enum(),
		Command:   message.CMD_ERROR.Enum(),
		AuthorId:  proto.Uint32(*msg.AuthorId),
		SessionId: proto.String(*msg.SessionId),
		Error: &message.Msg_Error{
			ErrorId: proto.Uint32(1),
		},
	}
	sendKanbanMsg(conn, answer)
}
開發者ID:Neodyme,項目名稱:obiwan-kanbanobi,代碼行數:13,代碼來源:connection.go

示例10: FreezeACL

// Freeze a ChannelACL into it a flattened protobuf-based structure
// ready to be persisted to disk.
func FreezeACL(aclEntry acl.ACL) (*freezer.ACL, error) {
	frozenAcl := &freezer.ACL{}
	if aclEntry.UserId != -1 {
		frozenAcl.UserId = proto.Uint32(uint32(aclEntry.UserId))
	} else {
		frozenAcl.Group = proto.String(aclEntry.Group)
	}
	frozenAcl.ApplyHere = proto.Bool(aclEntry.ApplyHere)
	frozenAcl.ApplySubs = proto.Bool(aclEntry.ApplySubs)
	frozenAcl.Allow = proto.Uint32(uint32(aclEntry.Allow))
	frozenAcl.Deny = proto.Uint32(uint32(aclEntry.Deny))
	return frozenAcl, nil
}
開發者ID:rok-kek,項目名稱:grumble,代碼行數:15,代碼來源:freeze.go

示例11: RespondRequest

// Responds to a TradeProposedEvent.
func (t *Trading) RespondRequest(requestId TradeRequestId, accept bool) {
	var resp uint32
	if accept {
		resp = 0
	} else {
		resp = 1
	}

	t.client.Write(NewClientMsgProtobuf(EMsg_EconTrading_InitiateTradeResponse, &CMsgTrading_InitiateTradeResponse{
		TradeRequestId: proto.Uint32(uint32(requestId)),
		Response:       proto.Uint32(resp),
	}))
}
開發者ID:jcoene,項目名稱:go-steam,代碼行數:14,代碼來源:trading.go

示例12: sendPermissionDenied

// Send permission denied by who, what, where
func (c *Client) sendPermissionDenied(who *Client, where *Channel, what acl.Permission) {
	pd := &mumbleproto.PermissionDenied{
		Permission: proto.Uint32(uint32(what)),
		ChannelId:  proto.Uint32(uint32(where.Id)),
		Session:    proto.Uint32(who.Session()),
		Type:       mumbleproto.PermissionDenied_Permission.Enum(),
	}
	err := c.sendMessage(pd)
	if err != nil {
		c.Panicf("%v", err.Error())
		return
	}
}
開發者ID:carriercomm,項目名稱:grumble,代碼行數:14,代碼來源:client.go

示例13: TestFrameworkRegisteredMessage

func TestFrameworkRegisteredMessage(t *testing.T) {
	// setup chanel to receive unmarshalled message
	eventQ := make(chan interface{})
	go func() {
		for msg := range eventQ {
			val, ok := msg.(*mesos.FrameworkRegisteredMessage)
			if !ok {
				t.Fatal("Failed to receive msg of type FrameworkRegisteredMessage")
			}
			if val.FrameworkId.GetValue() != "test-framework-1" {
				t.Fatal("Expected FrameworkRegisteredMessage.Framework.Id.Value not found.")
			}
			if val.MasterInfo.GetId() != "master-1" {
				t.Fatal("Expected FrameworkRegisteredMessage.Master.Id not found.")
			}
		}
	}()

	// Simulate FramworkRegisteredMessage request from master.
	proc, err := newSchedulerProcess(eventQ)
	if err != nil {
		t.Fatal(err)
	}
	proc.started = true
	proc.aborted = false
	if err != nil {
		t.Fatal("Unable to start Scheduler Process.	")
	}
	msg := &mesos.FrameworkRegisteredMessage{
		FrameworkId: &mesos.FrameworkID{Value: proto.String("test-framework-1")},
		MasterInfo: &mesos.MasterInfo{
			Id:   proto.String("master-1"),
			Ip:   proto.Uint32(123456),
			Port: proto.Uint32(12345),
		},
	}
	data, err := proto.Marshal(msg)
	if err != nil {
		t.Fatalf("Unable to marshal FrameworkRegisteredMessage, %v", err)
	}

	req := buildHttpRequest(t, "FrameworkRegisteredMessage", data)
	resp := httptest.NewRecorder()

	// ServeHTTP will unmarshal msg and place on passed channel (above)
	proc.ServeHTTP(resp, req)

	if resp.Code != http.StatusAccepted {
		t.Fatalf("Expecting server status %d but got status %d", http.StatusAccepted, resp.Code)
	}
}
開發者ID:nekto0n,項目名稱:gomes,代碼行數:51,代碼來源:schedproc_test.go

示例14: Freeze

// Freeze a User into a flattened protobuf-based structure
// ready to be persisted to disk.
func (user *User) Freeze() (fu *freezer.User, err error) {
	fu = new(freezer.User)

	fu.Id = proto.Uint32(user.Id)
	fu.Name = proto.String(user.Name)
	fu.CertHash = proto.String(user.CertHash)
	fu.Email = proto.String(user.Email)
	fu.TextureBlob = proto.String(user.TextureBlob)
	fu.CommentBlob = proto.String(user.CommentBlob)
	fu.LastChannelId = proto.Uint32(uint32(user.LastChannelId))
	fu.LastActive = proto.Uint64(user.LastActive)

	return
}
開發者ID:rok-kek,項目名稱:grumble,代碼行數:16,代碼來源:freeze.go

示例15: handleHello

func (p *Peer) handleHello(m *Manager, hello *protocol.Hello) {
	cookie, err := p.getSessionCookie()
	if err != nil {
		glog.Errorf("%s:Bad cookie: %s", p.String(), err.Error())
		p.UpdateStatus(HelloFailed)
		return
	}
	pubKey, err := crypto.ParsePublicKeyFromHash(hello.GetNodePublic())
	if err != nil {
		glog.Errorf("Bad public key: %X", hello.GetNodePublic())
		p.UpdateStatus(HelloFailed)
		return
	}
	ok, err := crypto.Verify(pubKey.SerializeUncompressed(), hello.GetNodeProof(), cookie)
	if !ok {
		glog.Errorf("%s:Bad signature: %X public key: %X hash: %X", p.String(), hello.GetNodeProof(), hello.GetNodePublic(), cookie)
		p.UpdateStatus(HelloFailed)
		return
	}
	if err != nil {
		glog.Errorf("%s:Bad signature verification: %s", p.String(), err.Error())
		p.UpdateStatus(HelloFailed)
		return
	}
	proof, err := m.Key.Sign(cookie)
	if err != nil {
		glog.Errorf("%s:Bad signature creation: %X", p.String(), cookie)
		p.UpdateStatus(HelloFailed)
		return
	}
	if err := p.ProcessHello(hello); err != nil {
		glog.Errorf("%s:%s", p.String(), err.Error())
		return
	}
	port, _ := strconv.ParseUint(m.Port, 10, 32)
	p.Outgoing <- &protocol.TMHello{
		FullVersion:     proto.String(m.Name),
		ProtoVersion:    proto.Uint32(uint32(maxVersion)),
		ProtoVersionMin: proto.Uint32(uint32(minVersion)),
		NodePublic:      []byte(m.PublicKey.String()),
		NodeProof:       proof,
		Ipv4Port:        proto.Uint32(uint32(port)),
		NetTime:         proto.Uint64(uint64(data.Now().Uint32())),
		NodePrivate:     proto.Bool(true),
		TestNet:         proto.Bool(false),
	}
	if hello.ProofOfWork != nil {
		go p.handleProofOfWork(hello.ProofOfWork)
	}
}
開發者ID:Zoramite,項目名稱:ripple,代碼行數:50,代碼來源:peer.go


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