当前位置: 首页>>代码示例>>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;未经允许,请勿转载。