本文整理匯總了Golang中github.com/getgauge/gauge/gauge_messages.Message類的典型用法代碼示例。如果您正苦於以下問題:Golang Message類的具體用法?Golang Message怎麽用?Golang Message使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Message類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: WriteGaugeMessage
func WriteGaugeMessage(message *gauge_messages.Message, conn net.Conn) error {
messageId := common.GetUniqueID()
message.MessageId = &messageId
data, err := proto.Marshal(message)
if err != nil {
return err
}
return Write(conn, data)
}
示例2: sendMessage
func (p *plugin) sendMessage(message *gauge_messages.Message) error {
messageID := common.GetUniqueID()
message.MessageId = &messageID
messageBytes, err := proto.Marshal(message)
if err != nil {
return err
}
err = conn.Write(p.connection, messageBytes)
if err != nil {
return fmt.Errorf("[Warning] Failed to send message to plugin: %s %s", p.descriptor.ID, err.Error())
}
return nil
}
示例3: sendMessage
func (plugin *plugin) sendMessage(message *gauge_messages.Message) error {
messageId := common.GetUniqueId()
message.MessageId = &messageId
messageBytes, err := proto.Marshal(message)
if err != nil {
return err
}
err = conn.Write(plugin.connection, messageBytes)
if err != nil {
return errors.New(fmt.Sprintf("[Warning] Failed to send message to plugin: %d %s", plugin.descriptor.Id, err.Error()))
}
return nil
}
示例4: GetResponseForGaugeMessage
func GetResponseForGaugeMessage(message *gauge_messages.Message, conn net.Conn) (*gauge_messages.Message, error) {
messageId := common.GetUniqueID()
message.MessageId = &messageId
data, err := proto.Marshal(message)
if err != nil {
return nil, err
}
responseBytes, err := WriteDataAndGetResponse(conn, data)
if err != nil {
return nil, err
}
responseMessage := &gauge_messages.Message{}
if err := proto.Unmarshal(responseBytes, responseMessage); err != nil {
return nil, err
}
if err := checkUnsupportedResponseMessage(responseMessage); err != nil {
return responseMessage, err
}
return responseMessage, err
}
示例5: checkUnsupportedResponseMessage
func checkUnsupportedResponseMessage(message *gauge_messages.Message) error {
if message.GetMessageType() == gauge_messages.Message_UnsupportedMessageResponse {
return fmt.Errorf("Unsupported Message response received. Message not supported. %s", message.GetUnsupportedMessageResponse().GetMessage())
}
return nil
}