client.go
func (c *Client) TriggerBatch(batch []Event) (*BufferedEvents, error) {
	hasEncryptedChannel := false
	// validate every channel name and every sockedID (if present) in batch
	for _, event := range batch {
		if !validChannel(event.Channel) {
			return nil, fmt.Errorf("The channel named %s has a non-valid name", event.Channel)
		}
		if err := validateSocketID(event.SocketId); err != nil {
			return nil, err
		}
		if isEncryptedChannel(event.Channel) {
			hasEncryptedChannel = true
		}
	}
	if hasEncryptedChannel {
		// validate EncryptionMasterKey
		if !validEncryptionKey(c.EncryptionMasterKey) {
			return nil, errors.New("Your encryptionMasterKey is not of the correct format")
		}
	}
	payload, err := encodeTriggerBatchBody(batch, c.EncryptionMasterKey)
	if err != nil {
		return nil, err
	}
	path := fmt.Sprintf("/apps/%s/batch_events", c.AppId)
	u, err := createRequestURL("POST", c.Host, path, c.Key, c.Secret, authTimestamp(), c.Secure, payload, nil, c.Cluster)
	if err != nil {
		return nil, err
	}
	response, err := c.request("POST", u, payload)
	if err != nil {
		return nil, err
	}
	return unmarshalledBufferedEvents(response)
}
func (c *Client) TriggerBatch(batch []Event) (*BufferedEvents, error) {
	hasEncryptedChannel := false
	// validate every channel name and every sockedID (if present) in batch
	for _, event := range batch {
		if !validChannel(event.Channel) {
			return nil, fmt.Errorf("The channel named %s has a non-valid name", event.Channel)
		}
		if err := validateSocketID(event.SocketId); err != nil {
			return nil, err
		}
		if isEncryptedChannel(event.Channel) {
			hasEncryptedChannel = true
		}
	}
	if hasEncryptedChannel {
		// validate EncryptionMasterKey
		if !validEncryptionKey(c.EncryptionMasterKey) {
			return nil, errors.New("Your encryptionMasterKey is not of the correct format")
		}
	}
	payload, err := encodeTriggerBatchBody(batch, c.EncryptionMasterKey)
	if err != nil {
		return nil, err
	}
	path := fmt.Sprintf("/apps/%s/batch_events", c.AppId)
	u, err := createRequestURL("POST", c.Host, path, c.Key, c.Secret, authTimestamp(), c.Secure, payload, nil, c.Cluster)
	if err != nil {
		return nil, err
	}
	response, err := c.request("POST", u, payload)
	if err != nil {
		return nil, err
	}
	return unmarshalledBufferedEvents(response)
}
func ( c * Client ) TriggerBatch ( batch [ ] Event ) ( * BufferedEvents , error ) { hasEncryptedChannel := false // validate every channel name and every sockedID (if present) in batch for _ , event := range batch { if ! validChannel ( event . Channel ) { return nil , fmt . Errorf ( " " , event . Channel ) } if err := validateSocketID ( event . SocketId ) ; err != nil { return nil , err } if isEncryptedChannel ( event . Channel ) { hasEncryptedChannel = true } } if hasEncryptedChannel { // validate EncryptionMasterKey if ! validEncryptionKey ( c . EncryptionMasterKey ) { return nil , errors . New ( " " ) } } payload , err := encodeTriggerBatchBody ( batch , c . EncryptionMasterKey ) if err != nil { return nil , err } path := fmt . Sprintf ( " " , c . AppId ) u , err := createRequestURL ( " " , c . Host , path , c . Key , c . Secret , authTimestamp ( ) , c . Secure , payload , nil , c . Cluster ) if err != nil { return nil , err } response , err := c . request ( " " , u , payload ) if err != nil { return nil , err } return unmarshalledBufferedEvents ( response ) }
/* TriggerBatch triggers multiple events on multiple types of channels in a single call:
    client.TriggerBatch([]pusher.Event{
	    { Channel: "donut-1", Name: "ev1", Data: "pippo1" },
	    { Channel: "private-encrypted-secretdonut", Name: "ev2", Data: "pippo2" },
    })
*/
/ * TriggerBatch triggers multiple events on multiple types of channels in a single call : client . TriggerBatch ( [] pusher . Event { { Channel : donut - 1 Name : ev1 Data : pippo1 } { Channel : private - encrypted - secretdonut Name : ev2 Data : pippo2 } } )