Skip to content

jgomez696/chaturbate-socket-server

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A socket server for publishing events from a Chaturbate profile.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 92.0%
  • Shell 8.0%