本文整理汇总了Golang中femebe.Message.Payload方法的典型用法代码示例。如果您正苦于以下问题:Golang Message.Payload方法的具体用法?Golang Message.Payload怎么用?Golang Message.Payload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类femebe.Message
的用法示例。
在下文中一共展示了Message.Payload方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: processIdentMsg
// Process the identity ('I') message, reporting the identity therein.
func processIdentMsg(msgInit msgInit, exit exitFn) string {
var m femebe.Message
msgInit(&m, exit)
// Read the remote system identifier string
if m.MsgType() != 'I' {
exit("expected identification ('I') message, "+
"but received %c", m.MsgType())
}
// hard-coded lengh limit, but it's very generous
if m.Size() > 10*KB {
log.Printf("oversized message string, msg size is %d",
m.Size())
}
s, err := femebe.ReadCString(m.Payload())
if err != nil {
exit("couldn't read identification string: %v",
err)
}
return s
}
示例2: processVerMsg
// Read the version message, calling exit if this is not a supported
// version.
func processVerMsg(msgInit msgInit, exit exitFn) {
var m femebe.Message
msgInit(&m, exit)
if m.MsgType() != 'V' {
exit("expected version ('V') message, "+
"but received %c", m.MsgType())
}
// hard-coded lengh limit, but it's very generous
if m.Size() > 10*KB {
log.Printf("oversized message string, msg size is %d",
m.Size())
}
s, err := femebe.ReadCString(m.Payload())
if err != nil {
exit("couldn't read version string: %v", err)
}
if !strings.HasPrefix(s, "PG-9.2.") ||
!strings.HasSuffix(s, "/logfebe-1") {
exit("protocol version not supported: %s", s)
}
}