當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Conn.Origin方法代碼示例

本文整理匯總了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
}
開發者ID:jrconlin,項目名稱:pushgo,代碼行數:11,代碼來源:packet_smoke_test.go

示例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
}
開發者ID:jrconlin,項目名稱:pushgo,代碼行數:35,代碼來源:api_smoke_test.go

示例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
}
開發者ID:shihuacai1989,項目名稱:pushgo,代碼行數:14,代碼來源:api_test.go

示例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
}
開發者ID:shihuacai1989,項目名稱:pushgo,代碼行數:6,代碼來源:packet_test.go

示例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
}
開發者ID:shihuacai1989,項目名稱:pushgo,代碼行數:6,代碼來源:packet_test.go


注:本文中的github.com/mozilla-services/pushgo/client.Conn.Origin方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。