Documentation
¶
Index ¶
- Constants
- func JoinGroup(rw http.ResponseWriter, req *http.Request)
- func LeaveGroup(rw http.ResponseWriter, req *http.Request)
- func SendGroupMessage(rw http.ResponseWriter, req *http.Request)
- func SendTopicMessage(rw http.ResponseWriter, req *http.Request)
- func SendUserMessage(rw http.ResponseWriter, req *http.Request)
- func UpdateMyself(rw http.ResponseWriter, req *http.Request)
- func VerifyRequest(req *http.Request) (isValid bool)
- type Group
- type GroupMessage
- type GroupOperation
- type GroupOperationResponse
- type GroupUser
- type Item
- type ItemMember
- type ItemUpdateNotification
- type TopicMessage
- type UpdateItemState
- type User
- type UserMessage
- type UserRegistrationResponseBody
- type UserRegistrationTokenAuthenticity
Constants ¶
const AppNamespace = "com.vernonsung.testquerygcs"
const BaseUrl = "/api/0.1/"
const GaeProjectNumber = "492596673998"
const GcmApiKey = "AIzaSyBgH4A9CdPgc-Kh54j5TLgKl7x3YCGBtOU"
const GcmGroupURL = "https://android.googleapis.com/gcm/notification"
GCM server
const GcmURL = "https://gcm-http.googleapis.com/gcm/send"
GCM server
const GroupKind = "Group"
const GroupRoot = "Group root"
const HttpHeaderInstanceId = "Instance-Id"
HTTP header
const InstanceIdVerificationUrl = "https://iid.googleapis.com/iid/info/"
GCM server
const ItemKind = "Item"
const ItemRoot = "Item Root"
const UserKind = "User"
const UserRoot = "User root"
Variables ¶
This section is empty.
Functions ¶
func JoinGroup ¶
func JoinGroup(rw http.ResponseWriter, req *http.Request)
PUT ./groups" Success: 204 No Content Failure: 400 Bad Request, 403 Forbidden, 500 Internal Server Error
func LeaveGroup ¶
func LeaveGroup(rw http.ResponseWriter, req *http.Request)
DELETE ./groups/xxx", xxx: Group name Header {"Instance-Id":"..."} Success returns 204 No Content Failure returns 400 Bad Request, 403 Forbidden, 500 Internal Server Error
func SendGroupMessage ¶
func SendGroupMessage(rw http.ResponseWriter, req *http.Request)
Receive a message from an APP instance. Check it's instancd ID. Send the message to the gruop. POST ./group-messages" Success: 204 No Content Failure: 400 Bad Request, 403 Forbidden, 404 NotFound, 500 InternalError
func SendTopicMessage ¶
func SendTopicMessage(rw http.ResponseWriter, req *http.Request)
Receive a message from an APP instance. Check it's instancd ID. Send the message to the topic. POST ./topic-messages" Success: 204 No Content Failure: 400 Bad Request, 403 Forbidden, 404 NotFound, 500 InternalError
func SendUserMessage ¶
func SendUserMessage(rw http.ResponseWriter, req *http.Request)
Receive a message from an APP instance. Check it's instancd ID. Send the message back. POST ./user-messages" Success: 204 No Content Failure: 400 Bad Request, 403 Forbidden
func UpdateMyself ¶
func UpdateMyself(rw http.ResponseWriter, req *http.Request)
PUT ./myself" Success: 200 OK Failure: 400 Bad Request
func VerifyRequest ¶
Types ¶
type Group ¶
type Group struct {
Name string `json:"name"`
Owner string `json:"owner"` // Instance ID
Members []string `json:"members"` // Instance ID list
NotificationKey string `json:"notificationkey"` // GCM device group unique ID
}
Data structure got from datastore group kind
type GroupMessage ¶
type GroupMessage struct {
// To authentication
InstanceId string `json:"instanceid"`
// To the target user
GroupName string `json:"groupname"`
Message string `json:"message"`
}
HTTP body of sending a message to a group
type GroupOperation ¶
type GroupOperation struct {
Operation string `json:"operation"` // "create", "add", "remove"
Notification_key_name string `json:"notification_key_name"` // A unique group name in a Google project
Notification_key string `json:"notification_key,omitempty"` // A unique key to identify a group
Registration_ids []string `json:"registration_ids"` // APP registration tokens in the group
}
HTTP body to send to Google Cloud Messaging server to manage device groups
type GroupOperationResponse ¶
type GroupOperationResponse struct {
Notification_key string `json:"notification_key"` // A unique key to identify a group
Error string `json:"error"` // Error message
}
HTTP body received from Google Cloud Messaging server
type GroupUser ¶
type GroupUser struct {
// To authentication
InstanceId string `json:"instanceid"`
// The group
GroupName string `json:"groupname"`
}
HTTP body of joining or leaving group requests from users
type Item ¶
type Item struct {
Id string `json:"id" datastore:"-"`
Image string `json:"image"`
Thumbnail string `json:"thumbnail"`
People int `json:"people"`
Attendant int `json:"attendant"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
CreateTime time.Time `json:"createtime"`
// Members are whom join this item. The first member is the item owner.
// When the first member leaves, delete the item.
Members []ItemMember `json:"members"`
// Google Cloud Messaging group unique name and ID. Reference: https://developers.google.com/cloud-messaging/notifications
GcmGroupName string `json:"gcmgroupname"`
GcmGroupKey string `json:"gcmgroupkey"`
}
type ItemMember ¶
type ItemUpdateNotification ¶
type TopicMessage ¶
type TopicMessage struct {
// To authentication
InstanceId string `json:"instanceid"`
// To the target user
Topic string `json:"topic"`
Message string `json:"message"`
}
HTTP body of sending a message to a topic
type User ¶
type User struct {
InstanceId string `json:"instanceid"`
RegistrationToken string `json:"registrationtoken"`
LastUpdateTime time.Time `json:"lastupdatetime"`
}
Data structure got from datastore user kind
type UserMessage ¶
type UserMessage struct {
// To authentication
InstanceId string `json:"instanceid"`
// To the target user
UserId string `json:"userid"` // Datastore user kind key string
Message string `json:"message"`
}
HTTP body of sending a message to a user
type UserRegistrationResponseBody ¶
type UserRegistrationResponseBody struct {
UserId string `json:"userid"`
}
HTTP response body to user registration
type UserRegistrationTokenAuthenticity ¶
type UserRegistrationTokenAuthenticity struct {
Application string `json:"application"`
AuthorizedEntity string `json:"authorizedEntity"`
}
HTTP response body from Google Instance ID authenticity service