ftc

package module
v0.0.0-...-5ff28ac Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2014 License: MIT Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

FTC Build Status GoDoc

FTC (fault tolerant connection) is an engine.io-compatible library that provides fault tolerant, persistent client-server connections.

A basic echo server is shown below and is compatible with the engine-io example.

package main

import (
	"io"
	"log"
	"net/http"

	"github.com/poptip/ftc"
)

func EchoServer(c *ftc.Conn) {
	io.Copy(c, c)
}

func main() {
	http.Handle("/engine.io/", ftc.NewServer(nil, ftc.Handler(EchoServer)))
	log.Println("Serving at localhost:5000...")
	log.Fatal(http.ListenAndServe(":5000", nil))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewServer

func NewServer(o *Options, h Handler) *server

NewServer allocates and returns a new server with the given options and handler. If nil options are passed, the defaults specified in the constants above are used instead.

Types

type Conn

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

Conn represents an FTC connection.

func (*Conn) Close

func (c *Conn) Close() error

Close closes the connection.

func (*Conn) Read

func (c *Conn) Read(p []byte) (int, error)

func (*Conn) Write

func (c *Conn) Write(p []byte) (int, error)

type Handler

type Handler func(*Conn)

A Handler is called by the server when a connection is opened successfully.

type Options

type Options struct {
	// BasePath is the base URL path that the server handles requests for.
	BasePath string
	// CookieName is the name of the cookie set upon successful handshake.
	CookieName string
}

Options are the parameters passed to the server.

Jump to

Keyboard shortcuts

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