Toggle navigation
Toggle navigation
This project
Loading...
Sign in
이준성
/
khuwitch
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Jinsu Park
2020-12-09 02:49:45 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ff9278903a3512a1849d48cdd61f5c07db34b9bd
ff927890
1 parent
4febe79b
Fix: errors
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
10 deletions
frontend/src/Channel.js
server/socket_server.js
frontend/src/Channel.js
View file @
ff92789
...
...
@@ -11,11 +11,11 @@ import tts from './tts';
// audioQueue에서 하나씩 뽑아서 재생한다.
tts
.
enableAudio
()
const
socket
=
io
.
connect
(
`http://server.oss.jinsu.me`
)
const
socket
=
io
.
connect
(
"http://server.oss.jinsu.me"
)
socket
.
on
(
"connect"
,
event
=>
{
// 테스트용으로 umi0410에게 입장.
// 다른 거 아무거나 채널이름을 넣으면 되겠지만, 그렇게 하고싶으면 백엔드에서 인자설정을 해줘야함.
socket
.
emit
(
"joinRoom"
,
'umi0410'
,
'진수봇'
)
//
socket.emit("joinRoom", 'umi0410', '진수봇')
})
// 말해야할 메시지가 왔을 때. 이건 따로 Component와 묶지 않아도 알아서 실행됩니다.
...
...
@@ -101,6 +101,7 @@ export class ChannelList extends React.Component {
channels
[
index
].
isPlay
=
true
;
// 기존 채널 재생을 중지하고 새로운 채널을 listen
console
.
log
(
"if"
)
quit
(
channels
[
this
.
state
.
xisPlaying
].
id
);
listen
(
channels
[
index
].
id
);
}
...
...
@@ -109,6 +110,7 @@ export class ChannelList extends React.Component {
else
{
channels
[
index
].
isPlay
=
true
;
// 채널 listen
console
.
log
(
"else"
)
listen
(
channels
[
index
].
id
);
}
...
...
@@ -121,13 +123,13 @@ export class ChannelList extends React.Component {
componentDidMount
()
{
console
.
log
(
'channel cdm'
);
fetch
(
`http://server.oss.jinsu.me/channels`
).
then
(
res
=>
res
.
json
())
fetch
(
'http://server.oss.jinsu.me/channels'
).
then
(
res
=>
res
.
json
())
.
then
(
data
=>
{
var
tmpChannels
=
[];
data
.
map
((
channel
,
index
)
=>
{
var
tmp
=
{
id
:
channel
.
display_name
||
" "
,
nickname
:
channel
.
name
||
" "
,
id
:
channel
.
name
||
" "
,
nickname
:
channel
.
display_
name
||
" "
,
category
:
channel
.
game
||
"Not playing"
,
view
:
channel
.
views
||
0
,
url
:
channel
.
url
||
"https://www.twitch.tv/"
,
...
...
server/socket_server.js
View file @
ff92789
...
...
@@ -38,7 +38,7 @@ app.get('/', (req, res) => {
});
app
.
get
(
'/channels'
,(
req
,
res
)
=>
{
//
console.log(channels)
console
.
log
(
channels
)
res
.
send
(
channels
)
});
...
...
@@ -91,11 +91,10 @@ app.get('/test',(req,res)=>{
////////////////////////oauth////////////////////////
async
function
JoinChannel
(
streamer
){
await
client
.
action
(
streamer
,
'KhuwitchBot 두두등장'
);
await
opts
.
channels
.
push
(
'#'
+
streamer
);
await
delete
client
;
async
function
JoinChannel
(
streamer
){
opts
.
channels
=
[(
'#'
+
streamer
)]
client
=
await
new
tmi
.
client
(
opts
);
client
.
channels
.
push
(
'#'
+
streamer
);
client
.
on
(
'message'
,
onMessageHandler
);
client
.
on
(
'connected'
,
onConnectedHandler
);
client
.
connect
();
...
...
@@ -123,6 +122,7 @@ io.on('connection', (socket) => {
});
socket
.
on
(
'chat message'
,
(
streamer
,
name
,
msg
)
=>
{
io
.
to
(
streamer
).
emit
(
'chat message'
,
name
,
msg
);
});
});
...
...
@@ -160,6 +160,7 @@ function onMessageHandler (target, context, msg, self) {
}
else
{
io
.
to
(
target
.
replace
(
'#'
,
''
)).
emit
(
'chat message'
,
context
[
"display-name"
],
msg
)
console
.
log
(
"메시지 발생"
,
context
[
"display-name"
],
msg
)
papago
.
detectchat
(
msg
,
client
,
io
,
target
);
}
...
...
Please
register
or
login
to post a comment