pusher

package
v0.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2015 License: BSD-2-Clause Imports: 15 Imported by: 0

README

A Go Lang Pusher Library

So much to write, so little information to tell you right now :)

Example

package main

import (
    "fmt"
    "github.com/timonv/pusher"
    "time"
)

func main() {
    client := pusher.NewClient("appId", "key", "secret", false)

    done := make(chan bool)

    go func() {
        err := client.Publish("test", "test", "test")
        if err != nil {
            fmt.Printf("Error %s\n", err)
        } else {
            fmt.Print("Message Published!")
        }
        done <- true
    }()

    // A basic timeout to make sure we don't wait forever
    select {
    case <-done:
        fmt.Println("\nDone")
    case <-time.After(1 * time.Minute):
        fmt.Println("\n:-( Timeout")
    }
}

License

MIT: Timon Vonk and Josh Kalderimis http://timon-josh.mit-license.org

Documentation

Index

Constants

View Source
const AuthVersion = "1.0"

Variables

View Source
var HttpClient = http.Client{}

Functions

This section is empty.

Types

type AuthPart

type AuthPart struct {
	// contains filtered or unexported fields
}

type Channel

type Channel struct {
	Name              string
	Occupied          bool `json:"occupied"`
	UserCount         int  `json:"user_count",omitempty`
	SubscriptionCount int  `json:"subscription_count",omitempty`
}

func (*Channel) String

func (c *Channel) String() string

type ChannelInfo

type ChannelInfo struct {
	UserCount int `json:"user_count"`
}

type ChannelList

type ChannelList struct {
	List map[string]ChannelInfo `json:"channels"`
}

func (*ChannelList) String

func (c *ChannelList) String() string

type Client

type Client struct {
	Host   string
	Scheme string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(appid, key, secret string) *Client

func (*Client) AllChannels

func (c *Client) AllChannels() (*ChannelList, error)

func (*Client) Channel

func (c *Client) Channel(name string, queryParameters map[string]string) (*Channel, error)

func (*Client) Channels

func (c *Client) Channels(queryParameters map[string]string) (*ChannelList, error)

func (*Client) Publish

func (c *Client) Publish(data, event string, channels ...string) error

func (*Client) Users

func (c *Client) Users(channelName string) (*UserList, error)

type OrderedAuthParts

type OrderedAuthParts []*AuthPart

func (OrderedAuthParts) Len

func (s OrderedAuthParts) Len() int

func (OrderedAuthParts) Less

func (s OrderedAuthParts) Less(i, j int) bool

func (OrderedAuthParts) Swap

func (s OrderedAuthParts) Swap(i, j int)

type Payload

type Payload struct {
	Name     string   `json:"name"`
	Channels []string `json:"channels"`
	Data     string   `json:"data"`
}

type Signature

type Signature struct {
	// contains filtered or unexported fields
}

func (*Signature) EncodedQuery

func (s *Signature) EncodedQuery() string

func (*Signature) Sign

func (s *Signature) Sign() string

type UserInfo

type UserInfo struct {
	Id int `json:"id"`
}

type UserList

type UserList struct {
	List []UserInfo `json:"users"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL