You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

faye

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

faye

Simple pub/sub messaging for the web


Version published
Weekly downloads
524K
increased by0.59%
Maintainers
1
Created
Weekly downloads
 

Package description

What is faye?

Faye is a publish-subscribe messaging system based on the Bayeux protocol. It is designed to be used in both Node.js and browser environments, allowing for real-time messaging and communication between clients and servers.

What are faye's main functionalities?

Publish-Subscribe Messaging

This code demonstrates how to set up a Faye server and client for publish-subscribe messaging. The server listens on port 8000, and the client subscribes to the '/messages' channel to receive messages. The client also publishes a message to the same channel.

const faye = require('faye');

// Create a new Faye server
const server = new faye.NodeAdapter({mount: '/faye', timeout: 45});

// Start the server
server.listen(8000);

// Create a client
const client = new faye.Client('http://localhost:8000/faye');

// Subscribe to a channel
client.subscribe('/messages', function(message) {
  console.log('Received message:', message);
});

// Publish a message to the channel
client.publish('/messages', {text: 'Hello, world!'});

Client-Server Communication

This code demonstrates client-server communication using Faye. The server is set up to listen on port 8000, and the client subscribes to the '/chat' channel to handle incoming messages. The client also publishes a message to the '/chat' channel.

const faye = require('faye');

// Create a new Faye server
const server = new faye.NodeAdapter({mount: '/faye', timeout: 45});

// Start the server
server.listen(8000);

// Create a client
const client = new faye.Client('http://localhost:8000/faye');

// Define a function to handle incoming messages
function handleMessage(message) {
  console.log('Received message:', message);
}

// Subscribe to a channel
client.subscribe('/chat', handleMessage);

// Publish a message to the channel
client.publish('/chat', {user: 'Alice', text: 'Hi there!'});

Browser Integration

This code demonstrates how to integrate Faye with a browser environment. It includes the Faye browser script and sets up a client that subscribes to the '/notifications' channel to receive messages. The client also publishes a message to the same channel.

<script src="https://cdn.jsdelivr.net/npm/faye/browser/faye-browser-min.js"></script>
<script>
  // Create a client
  var client = new Faye.Client('http://localhost:8000/faye');

  // Subscribe to a channel
  client.subscribe('/notifications', function(message) {
    console.log('Received notification:', message);
  });

  // Publish a message to the channel
  client.publish('/notifications', {title: 'New Notification', body: 'You have a new message!'});
</script>

Other packages similar to faye

Changelog

Source

0.8.11 / 2014-07-08

  • Make some changes to JSON-P responses to mitigate the Rosetta Flash attack
  • http://miki.it/blog/2014/7/8/abusing-jsonp-with-rosetta-flash/

Readme

Source

= Faye

  • http://faye.jcoglan.com
  • http://groups.google.com/group/faye-users
  • http://github.com/faye/faye

Faye is a set of tools for dirt-simple publish-subscribe messaging between web clients. It ships with easy-to-use message routing servers for Node.js and Rack applications, and clients that can be used on the server and in the browser.

See http://faye.jcoglan.com for documentation.

== Questions, issues, ideas

Please raise questions on the mailing list: http://groups.google.com/group/faye-users, and feel free to announce and share ideas on Faye-related projects here too. I'd appreciate it if we only use the GitHub issue tracker for bona fide bugs; You'll probably get better and quicker answers to questions from the mailing list.

== Development

To hack on Faye, you'll need Ruby in order to build both the Gem and the NPM package. There are also a few submodules we use for testing. The following should get you up and running:

Download the code from Git

git clone git://github.com/faye/faye.git cd faye git submodule update --init --recursive

Install dependencies

bundle install npm install

Build Faye

bundle exec jake

Run tests

bundle exec rspec -c spec/ node spec/node.js

Install Ruby gem

gem build faye.gemspec gem install faye-x.x.x.gem

Install NPM package

npm install build

== To-do

  • Provide reflection API for internal stats on channels, subscriptions, message queues
  • (Maybe) build a monitoring GUI into the server
  • Add sugar for authentication extensions for protected subscribe + publish
  • Provide support for user-defined /service/* channels
  • Let local server-side clients listen to /meta/* channels

== License

(The MIT License)

Copyright (c) 2009-2013 James Coglan and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Keywords

FAQs

Package last updated on 08 Jul 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc