本文整理匯總了Golang中github.com/mozilla-services/pushgo/client.Conn.Origin方法的典型用法代碼示例。如果您正苦於以下問題:Golang Conn.Origin方法的具體用法?Golang Conn.Origin怎麽用?Golang Conn.Origin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/mozilla-services/pushgo/client.Conn
的用法示例。
在下文中一共展示了Conn.Origin方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: decodeCaseACK
func decodeCaseACK(c *client.Conn, fields client.Fields, statusCode int, errorText string) (client.Packet, error) {
if len(errorText) > 0 {
return nil, &client.ServerError{
MessageType: "ack",
Origin: c.Origin(),
Message: errorText,
StatusCode: statusCode,
}
}
return nil, nil
}
示例2: decodeServerInvalidACK
func decodeServerInvalidACK(c *client.Conn, fields client.Fields, statusCode int, errorText string) (client.Packet, error) {
if len(errorText) == 0 {
return nil, nil
}
updates, hasUpdates := fields["updates"].([]interface{})
if !hasUpdates {
return nil, &client.IncompleteError{
MessageType: "ack",
Origin: c.Origin(),
Field: "updates"}
}
reply := ServerInvalidACK{
Updates: make([]client.Update, len(updates)),
StatusCode: statusCode,
}
for index, field := range updates {
var (
update map[string]interface{}
channelId string
version float64
ok bool
)
if update, ok = field.(map[string]interface{}); !ok {
return nil, &client.IncompleteError{MessageType: "ack", Origin: c.Origin(), Field: "update"}
}
if channelId, ok = update["channelID"].(string); !ok {
return nil, &client.IncompleteError{MessageType: "ack", Origin: c.Origin(), Field: "channelID"}
}
if version, ok = update["version"].(float64); !ok {
return nil, &client.IncompleteError{MessageType: "ack", Origin: c.Origin(), Field: "version"}
}
reply.Updates[index] = client.Update{ChannelId: channelId, Version: int64(version)}
}
return reply, nil
}
示例3: decodeUnregisterReply
func decodeUnregisterReply(c *client.Conn, fields client.Fields, statusCode int, errorText string) (client.Packet, error) {
if len(errorText) > 0 {
return nil, &client.ServerError{"unregister", c.Origin(), errorText, statusCode}
}
channelId, hasChannelId := fields["channelID"].(string)
if !hasChannelId {
return nil, &client.IncompleteError{"register", c.Origin(), "channelID"}
}
reply := ServerUnregister{
StatusCode: statusCode,
ChannelId: channelId,
}
return reply, nil
}
示例4: decodeCaseACK
func decodeCaseACK(c *client.Conn, fields client.Fields, statusCode int, errorText string) (client.Packet, error) {
if len(errorText) > 0 {
return nil, &client.ServerError{"ack", c.Origin(), errorText, statusCode}
}
return nil, nil
}
示例5: decodePing
func decodePing(c *client.Conn, fields client.Fields, statusCode int, errorText string) (client.Packet, error) {
if len(errorText) > 0 {
return nil, &client.ServerError{"ping", c.Origin(), errorText, statusCode}
}
return ServerPing{statusCode}, nil
}