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

1.0.4 / 2020-04-28

  • Fix /meta/* channel recognition bug in the server that enables authentication bypass
    • https://blog.jcoglan.com/2020/04/28/authentication-bypass-in-faye/

Readme

Source

Faye

Faye is a set of tools for 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.

  • Documentation: http://faye.jcoglan.com
  • Mailing list: http://groups.google.com/group/faye-users
  • Bug tracker: http://github.com/faye/faye/issues
  • Source code: http://github.com/faye/faye

License

(The MIT License)

Copyright (c) 2009-2020 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 28 Apr 2020

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