fayeserver

package
v0.0.0-...-62f173d Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2016 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Faye Server

TODO: factor out the code and clean things up a little, commit - works with firefox/chrome/safari on mac with long-polling/eventsource support TODO: pure long-polling TODO: callback-polling TODO: cross-origin-polling

Created by Paul Crawford Copyright (c) 2013. All rights reserved.

Index

Constants

View Source
const CHANNEL_CONNECT = "/meta/connect"
View Source
const CHANNEL_DISCONNECT = "/meta/disconnect"
View Source
const CHANNEL_HANDSHAKE = "/meta/handshake"
View Source
const CHANNEL_SUBSCRIBE = "/meta/subscribe"
View Source
const CHANNEL_UNSUBSCRIBE = "/meta/unsubscribe"

Variables

This section is empty.

Functions

func Start

func Start(addr string)

Types

type Client

type Client struct {
	ClientId     string
	WriteChannel chan []byte
	ClientSubs   []string
}

Client

Clients represent connected Faye Clients, each has an Id negotiated during handshake, a write channel tied to their network connection and a list of subscriptions(faye channels) that have been subscribed to by the client.

type Connection

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

type FayeMessage

type FayeMessage struct {
	Channel                  string      `json:"channel"`
	ClientId                 string      `json:"clientId,omitempty"`
	Subscription             string      `json:"subscription,omitempty"`
	Data                     interface{} `json:"data,omitempty"`
	Id                       string      `json:"id,omitempty"`
	SupportedConnectionTypes []string    `json:"supportedConnectionTypes,omitempty"`
}

type FayeResponse

type FayeResponse struct {
	Channel                  string                 `json:"channel,omitempty"`
	Successful               bool                   `json:"successful,omitempty"`
	Version                  string                 `json:"version,omitempty"`
	SupportedConnectionTypes []string               `json:"supportedConnectionTypes,omitempty"`
	ConnectionType           string                 `json:"connectionType,omitempty"`
	ClientId                 string                 `json:"clientId,omitempty"`
	Advice                   map[string]interface{} `json:"advice,omitempty"`
	Subscription             string                 `json:"subscription,omitempty"`
	Error                    string                 `json:"error,omitempty"`
	Id                       string                 `json:"id,omitempty"`
	Data                     interface{}            `json:"data,omitempty"`
	Ext                      interface{}            `json:"ext,omitempty"`
}

type FayeServer

type FayeServer struct {
	Connections   []Connection
	Subscriptions map[string][]Client
	SubMutex      sync.RWMutex
	Clients       map[string]Client
	ClientMutex   sync.RWMutex
	// contains filtered or unexported fields
}

func NewFayeServer

func NewFayeServer() *FayeServer

Instantiate a new faye server

func (*FayeServer) DisconnectChannel

func (f *FayeServer) DisconnectChannel(c chan []byte)

func (*FayeServer) HandleMessage

func (f *FayeServer) HandleMessage(message []byte, c chan []byte) ([]byte, error)

func (*FayeServer) UpdateClientChannel

func (f *FayeServer) UpdateClientChannel(clientId string, c chan []byte) bool

updateClientChannel

Jump to

Keyboard shortcuts

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