Socket
Socket
Sign inDemoInstall

faye

Package Overview
Dependencies
6
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

faye

Simple pub/sub messaging for the web


Version published
Weekly downloads
417K
decreased by-12.62%
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.4.0 / 2020-07-31

  • Implement TLS certificate verification and enable it by default in the Ruby client class Faye::Client
  • Add a :tls option to the Ruby client with sub-field :verify_peer for configuring TLS verification
  • Officially support the tls option in the Node.js client, whose contents are forward to the https and tls modules as appropriate

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

Keywords

FAQs

Package last updated on 31 Jul 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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc