Showing
2 changed files
with
27 additions
and
0 deletions
... | @@ -5,6 +5,31 @@ import PersonIcon from "@material-ui/icons/Person"; | ... | @@ -5,6 +5,31 @@ import PersonIcon from "@material-ui/icons/Person"; |
5 | import PlayArrowIcon from '@material-ui/icons/PlayArrow'; | 5 | import PlayArrowIcon from '@material-ui/icons/PlayArrow'; |
6 | import PauseIcon from '@material-ui/icons/Pause'; | 6 | import PauseIcon from '@material-ui/icons/Pause'; |
7 | import { WatchOutlined } from "@material-ui/icons"; | 7 | import { WatchOutlined } from "@material-ui/icons"; |
8 | +import io from 'socket.io-client' | ||
9 | +import tts from './tts'; | ||
10 | + | ||
11 | +const socket = io.connect("http://localhost:3000") | ||
12 | +socket.on("connect", event=>{ | ||
13 | + // 테스트용으로 umi0410에게 입장. | ||
14 | + // 다른 거 아무거나 채널이름을 넣으면 되겠지만, 그렇게 하고싶으면 백엔드에서 인자설정을 해줘야함. | ||
15 | + socket.emit("joinRoom", 'umi0410', '진수봇') | ||
16 | +}) | ||
17 | + | ||
18 | +// 말해야할 메시지가 왔을 때. 이건 따로 Component와 묶지 않아도 알아서 실행됩니다. | ||
19 | +socket.on('chat message', (name, msg)=>{ | ||
20 | + console.log(msg) | ||
21 | + tts.speak(msg) | ||
22 | +}) | ||
23 | + | ||
24 | +// 해당 채널을 재생하고자할 때 실행시켜주세요. | ||
25 | +const listen = (channelName)=>{ | ||
26 | + socket.emit("joinRoom", channelName, "dummy name") // name이 뭔지 대연이도 잘 모름. | ||
27 | +} | ||
28 | + | ||
29 | +// 해당 채널을 재생 안하도록 할 때 실행시켜주세요. | ||
30 | +const quit = (channelName)=>{ | ||
31 | + socket.emit("leaveRoom". channelName, "dummy name") // name이 뭔지 대연이도 잘 모름. | ||
32 | +} | ||
8 | 33 | ||
9 | export function Channel(props) { | 34 | export function Channel(props) { |
10 | const channel = props.channel; | 35 | const channel = props.channel; |
... | @@ -34,6 +59,7 @@ export class ChannelList extends React.Component { | ... | @@ -34,6 +59,7 @@ export class ChannelList extends React.Component { |
34 | 59 | ||
35 | // data for test | 60 | // data for test |
36 | const test = [ | 61 | const test = [ |
62 | + {"name": "umi0410 진수", "view": 123124124, "game": "game2" , "url": "https://www.twitch.tv/umi0410"}, | ||
37 | {"name": "name1", "view": 999, "game": "game1" ,"url": "https://www.twitch.tv", "thumbnail": "https://upload.wikimedia.org/wikipedia/commons/2/26/Twitch_logo.svg"}, | 63 | {"name": "name1", "view": 999, "game": "game1" ,"url": "https://www.twitch.tv", "thumbnail": "https://upload.wikimedia.org/wikipedia/commons/2/26/Twitch_logo.svg"}, |
38 | {"name": "name2", "view": 123124124, "game": "game2" , "url": "https://www.twitch.tv"}, | 64 | {"name": "name2", "view": 123124124, "game": "game2" , "url": "https://www.twitch.tv"}, |
39 | {"name": "name1", "view": 999, "game": "game1" ,"url": "https://www.twitch.tv", "thumbnail": "https://upload.wikimedia.org/wikipedia/commons/2/26/Twitch_logo.svg"}, | 65 | {"name": "name1", "view": 999, "game": "game1" ,"url": "https://www.twitch.tv", "thumbnail": "https://upload.wikimedia.org/wikipedia/commons/2/26/Twitch_logo.svg"}, |
... | @@ -44,6 +70,7 @@ export class ChannelList extends React.Component { | ... | @@ -44,6 +70,7 @@ export class ChannelList extends React.Component { |
44 | {"name": "name2", "view": 123124124, "game": "game2" , "url": "https://www.twitch.tv"}, | 70 | {"name": "name2", "view": 123124124, "game": "game2" , "url": "https://www.twitch.tv"}, |
45 | {"name": "name1", "view": 999, "game": "game1" ,"url": "https://www.twitch.tv", "thumbnail": "https://upload.wikimedia.org/wikipedia/commons/2/26/Twitch_logo.svg"}, | 71 | {"name": "name1", "view": 999, "game": "game1" ,"url": "https://www.twitch.tv", "thumbnail": "https://upload.wikimedia.org/wikipedia/commons/2/26/Twitch_logo.svg"}, |
46 | {"name": "name2", "view": 123124124, "game": "game2" , "url": "https://www.twitch.tv"}, | 72 | {"name": "name2", "view": 123124124, "game": "game2" , "url": "https://www.twitch.tv"}, |
73 | + | ||
47 | ] | 74 | ] |
48 | 75 | ||
49 | this.state = { | 76 | this.state = { | ... | ... |
frontend/src/websocket.js
0 → 100644
File mode changed
-
Please register or login to post a comment