Git Product home page Git Product logo

chaturbate-socket-server's Introduction

Chaturbate Socket Server

build status coverage status dependencies dev dependencies npm version

A socket server that publishes Chaturbate events from a profile.

Installation

npm install @paulallen87/chaturbate-socket-server

Server Usage

const app = express();
const server = http.createServer(app);
const cb = new ChaturbateSocketServer(server);

process.on('exit', () => {
  cb.stop();
  server.close();
});

server.listen(8080, () => {
  console.log(`Listening on ${server.address().port}`);
});

Client Usage

See chaturbate-events](https://github.com/paulallen87/chaturbate-events#events) module for more details.

const socket = io();

// username of the room to monitor 
const USERNAME = 'myusername'; 

socket.on('connect', () => {
  console.log('connected')
  // tell the backend to load this profile
  socket.emit('init', USERNAME);
});

socket.on('init', (e) => {
  console.log(`Welcome to ${e.room}'s room!`);
  console.log(`Current room subject is: ${e.subject}`);
});

socket.on('room_entry', (e) => {
  console.log(`${e.user.username} has joined the room`);
});

socket.on('room_leave', (e) => {
  console.log(`${e.user.username} has left the room`); 
});

socket.on('tip', (e) => {
  console.log(`${e.user.username} tipped ${e.amount} tokens`);   
});

socket.on('room_message', (e) => {
  console.log(`${e.user.username}: ${e.message}`);  
});

socket.on('disconnect', () => {
  console.log('disconnect')
});

Emits

init

The client can emit this message with a username as the payload. The server will load a chaturbate-controller and respond with an init event.

Events

connected

Called when the socket is connected.

init

Called when the profile has been initialized by the chaturbate-controller

The payload consists of all the properties on the chaturbate-controller.

Chaturbate Events

All events supported by chaturbate-events are also broadcasted on these socket connections.

Tests

npm test

chaturbate-socket-server's People

Contributors

paulallen87 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.