本文整理汇总了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
}
示例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
}
示例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
}
示例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)
}
示例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)
}
示例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
}
示例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),
}
}
示例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
}
示例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)
}
示例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
}
示例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),
}))
}
示例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
}
}
示例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)
}
}
示例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
}
示例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)
}
}