本文整理汇总了Golang中github.com/agl/pond/protos.Request类的典型用法代码示例。如果您正苦于以下问题:Golang Request类的具体用法?Golang Request怎么用?Golang Request使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Request类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: doCreateAccount
func (c *client) doCreateAccount() error {
_, _, err := parseServer(c.server, c.dev)
if err != nil {
return err
}
if !c.dev {
// Check that Tor is running.
testConn, err := net.Dial("tcp", c.torAddress)
if err != nil {
return errors.New("Failed to connect to local Tor: " + err.Error())
}
testConn.Close()
}
c.ui.Actions() <- SetText{name: "status", text: "Generating keys..."}
c.ui.Signal()
c.randBytes(c.identity[:])
curve25519.ScalarBaseMult(&c.identityPublic, &c.identity)
c.ui.Actions() <- SetText{name: "status", text: "Connecting..."}
c.ui.Signal()
conn, err := c.dialServer(c.server, false)
if err != nil {
return err
}
defer conn.Close()
c.ui.Actions() <- SetText{name: "status", text: "Requesting new account..."}
c.ui.Signal()
c.generation = uint32(c.randId())
request := new(pond.Request)
request.NewAccount = &pond.NewAccount{
Generation: proto.Uint32(c.generation),
Group: c.groupPriv.Group.Marshal(),
}
if err := conn.WriteProto(request); err != nil {
return err
}
reply := new(pond.Reply)
if err := conn.ReadProto(reply); err != nil {
return err
}
if err := replyToError(reply); err != nil {
return err
}
c.ui.Actions() <- SetText{name: "status", text: "Done"}
c.ui.Signal()
return nil
}
示例2: doCreateAccount
func (c *client) doCreateAccount(displayMsg func(string)) error {
_, _, err := parseServer(c.server, c.dev)
if err != nil {
return err
}
if !c.dev {
// Check that Tor is running.
testConn, err := net.Dial("tcp", c.torAddress)
if err != nil {
return errors.New("Failed to connect to local Tor: " + err.Error())
}
testConn.Close()
}
displayMsg("Connecting...")
conn, err := c.dialServer(c.server, false)
if err != nil {
return err
}
defer conn.Close()
displayMsg("Requesting new account...")
c.generation = uint32(c.randId())
request := new(pond.Request)
request.NewAccount = &pond.NewAccount{
Generation: proto.Uint32(c.generation),
Group: c.groupPriv.Group.Marshal(),
}
if err := conn.WriteProto(request); err != nil {
return err
}
reply := new(pond.Reply)
if err := conn.ReadProto(reply); err != nil {
return err
}
if err := replyToError(reply); err != nil {
return err
}
displayMsg("Done")
return nil
}