1.2.1 • Published 6 years ago

@paulallen87/chaturbate-socket-server v1.2.1

Weekly downloads
3
License
GPL-3.0
Repository
github
Last release
6 years ago

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
1.2.1

6 years ago

1.0.17

7 years ago

1.0.16

7 years ago

1.0.15

7 years ago

1.0.14

7 years ago

1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago