Skip to content

Commit

Permalink
Working on socket server
Browse files Browse the repository at this point in the history
  • Loading branch information
petercunha committed May 30, 2020
1 parent 43606ce commit 6b73bc8
Show file tree
Hide file tree
Showing 6 changed files with 792 additions and 3 deletions.
3 changes: 2 additions & 1 deletion frontend/package.json
Expand Up @@ -14,7 +14,8 @@
"react": "^16.8.6",
"react-audio-player": "^0.11.1",
"react-dom": "^16.8.6",
"react-helmet": "^5.2.1"
"react-helmet": "^5.2.1",
"socket.io-client": "^2.3.0"
},
"keywords": [
"gatsby"
Expand Down
14 changes: 12 additions & 2 deletions frontend/src/pages/index.js
@@ -1,13 +1,13 @@
import React from 'react'
import axios from 'axios'

import ReactAudioPlayer from 'react-audio-player'
import Layout from '../components/layout'
import Footer from './footer'
import greet from '../lib/greeting'
import socketIOClient from 'socket.io-client'

// TTS API
const API = (voice, text) => `https://api.streamelements.com/kappa/v2/speech?voice=${voice}&text=${text}`
const ENDPOINT = "http://127.0.0.1:3000";

// How many seconds a user must wait if Streamlabs is rate limiting us
const COOLDOWN = 5
Expand All @@ -29,10 +29,20 @@ class Index extends React.Component {
this.handleVoiceChange = this.handleVoiceChange.bind(this)
this.handleSubmit = this.handleSubmit.bind(this)

// Connect to Socket.io
// this.setupSockets()

// Print message in console
greet()
}

setupSockets() {
const socket = socketIOClient(ENDPOINT);
socket.on("update", data => {
console.log(data);
});
}

handleTextChange(event) {
this.setState({ text: event.target.value })
}
Expand Down

0 comments on commit 6b73bc8

Please sign in to comment.