Skip to content

Commit 4b8e622

Browse files
committed
feat: 파일전송, 연결 상태처리
1 parent e94ccad commit 4b8e622

File tree

6 files changed

+55
-226
lines changed

6 files changed

+55
-226
lines changed

frontend/contents/css/style.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@ button:hover {
133133
background-color: #cf402f;
134134
}
135135
button[disabled] {
136-
color: #ccc;
136+
background-color: #c4918b;
137137
}
138138
button[disabled]:hover {
139-
background-color: #d84a38;
139+
cursor: default;
140140
}
141141
video {
142142
margin: 0 0 20px 0;

frontend/views/examples/data-channel/css/main.css

Lines changed: 8 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@
66
*
77
*/
88

9-
input[type='text'] {
10-
padding: 6px 10px;
11-
width: 120px;
12-
height: 30px;
13-
border: solid 1px #bbb;
14-
font-size: 1.3em;
15-
}
16-
179
.wrap {
1810
margin-top: 30px;
1911
position: relative;
@@ -22,7 +14,7 @@ input[type='text'] {
2214
}
2315

2416
.wrap p {
25-
font-size: 1.25em;
17+
font-size: 20px;
2618
}
2719

2820
.wrap button {
@@ -31,92 +23,25 @@ input[type='text'] {
3123
vertical-align: top;
3224
}
3325

34-
.room-info {
35-
vertical-align: top;
36-
}
37-
38-
/********************************************
39-
Below room style
40-
*********************************************/
41-
video {
42-
margin: 0 0 20px 0;
43-
width: 100%;
44-
z-index: 1;
45-
background: #222;
46-
border: solid 1px #fff;
47-
transition: all 0.6s ease-out;
48-
}
49-
50-
video.effect {
51-
transform: scale(1, 1);
52-
}
53-
54-
.room-component {
55-
display: none;
56-
}
57-
58-
#video-wrap {
59-
position: relative;
60-
margin: 0 auto;
61-
min-height: 620px;
62-
}
63-
64-
#video-wrap .buttons {
65-
position: absolute;
66-
bottom: 0;
67-
}
68-
6926
#file-wrap {
7027
margin: 10px 0;
7128
padding: 30px 0;
7229
text-align: left;
7330
}
7431

75-
#local {
76-
position: absolute;
77-
top: 4%;
78-
right: 2%;
79-
width: 340px;
80-
height: 220px;
81-
border: solid 1px #fff;
82-
}
83-
84-
#local-video {
85-
position: absolute;
86-
top: 0;
87-
left: 0;
88-
}
89-
90-
#share-wrap {
91-
display: none;
92-
margin: 10px 0;
93-
}
94-
95-
.room #enter-wrap,
96-
.connected #create-wrap,
97-
.connected #wait-wrap {
98-
display: none;
99-
}
100-
.connected #local-video {
101-
top: 2px;
102-
left: 2px !important;
103-
width: 150px !important;
104-
border: solid 1px #fff;
105-
z-index: 2;
32+
#file-wrap progress {
33+
width: 100%;
10634
}
10735

108-
.room #share-wrap {
109-
display: block;
36+
#connection-status i {
37+
font-size: 60px;
11038
}
11139

112-
.room #wait-wrap {
40+
#connection-status .people-two,
41+
.connected #connection-status .people-one {
11342
display: none;
11443
}
11544

116-
.room .room-component {
45+
.connected #connection-status .people-two {
11746
display: block;
11847
}
119-
120-
.room #content {
121-
padding-top: 30px;
122-
}

frontend/views/examples/data-channel/index.ejs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,21 @@
33

44
<div id="content">
55
<div class="wrap">
6-
<section id="share-wrap">
7-
<a href="#" id="unique-token">Share this room link</a>
6+
<section id="connection-status">
7+
<div class="people-one">
8+
<i class="fas fa-child"></i>
9+
<p>혼자예요</p>
10+
</div>
11+
<div class="people-two">
12+
<i class="fas fa-people-arrows"></i>
13+
<p>둘이예요</p>
14+
</div>
815
</section>
916

1017
<section id="file-wrap">
1118
<div class="buttons">
1219
<input type="file" id="file" /><br />
13-
<button id="btn-send">Send</button>
20+
<button id="btn-send" disabled>Send</button>
1421
</div>
1522

1623
<div class="progress">

frontend/views/examples/data-channel/js/main.js

Lines changed: 5 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,8 @@ function handleFileInputChange() {
4848
function onDetectUser() {
4949
console.log('onDetectUser');
5050

51-
// TODO: 연결 UI 처리
52-
53-
// $waitWrap.innerHTML = `
54-
// <div class="room-info">
55-
// <p>당신을 기다리고 있어요. 참여 하실래요?</p>
56-
// <button id="btn-join">Join</button>
57-
// </div>
58-
// `;
59-
60-
// document.querySelector('#btn-join').addEventListener('click', (e) => {
61-
// e.target.disabled = true;
62-
// isOffer = true;
63-
// getUserMedia();
64-
// });
65-
// $createWrap.classList.add('slideup');
51+
$btnSend.disabled = false;
52+
$body.classList.add('connected');
6653
}
6754

6855
/**
@@ -91,10 +78,9 @@ function onLeave(userId) {
9178
console.log('onLeave', arguments);
9279

9380
if (remoteUserId === userId) {
94-
document.querySelector('#remote-video').remove();
95-
$body.classList.remove('connected');
96-
$body.classList.add('wait');
9781
remoteUserId = null;
82+
$body.classList.remove('connected');
83+
$btnSend.disabled = true;
9884
}
9985
}
10086

@@ -134,45 +120,14 @@ function send(data) {
134120
function setRoomToken() {
135121
const hashValue = (Math.random() * new Date().getTime()).toString(32).toUpperCase().replace(/\./g, '-');
136122

137-
if (location.hash.length > 2) {
138-
$uniqueToken.href = location.href;
139-
} else {
123+
if (location.hash.length < 2) {
140124
location.hash = '#' + hashValue;
141125
}
142126
}
143-
144-
/**
145-
* 클립보드 복사
146-
*/
147-
function setClipboard() {
148-
$uniqueToken.addEventListener('click', () => {
149-
const link = location.href;
150-
151-
if (window.clipboardData) {
152-
window.clipboardData.setData('text', link);
153-
alert('Copy to Clipboard successful.');
154-
} else {
155-
window.prompt('Copy to clipboard: Ctrl+C, Enter', link); // Copy to clipboard: Ctrl+C, Enter
156-
}
157-
});
158-
}
159-
160127
/**
161128
* DOM 이벤트 바인딩
162129
*/
163130
function bindDomEvent() {
164-
// document.querySelector('#btn-start').addEventListener('click', getUserMedia);
165-
// document.querySelector('#btn-camera')?.addEventListener('click', (e) => {
166-
// const $this = e.target;
167-
// $this.classList.toggle('active');
168-
// mediaHandler[$this.className === 'active' ? 'pauseVideo' : 'resumeVideo']();
169-
// });
170-
// document.querySelector('#btn-mic')?.addEventListener('click', (e) => {
171-
// const $this = e.target;
172-
// $this.classList.toggle('active');
173-
// mediaHandler[$this.className === 'active' ? 'muteAudio' : 'unmuteAudio']();
174-
// });
175-
176131
$btnSend.addEventListener('click', () => {
177132
peerHandler.sendData($fileInput.files[0]);
178133
});
@@ -183,7 +138,6 @@ function bindDomEvent() {
183138
*/
184139
function initialize() {
185140
setRoomToken();
186-
setClipboard();
187141
roomId = location.href.replace(/\/|:|#|%|\.|\[|\]/g, '');
188142
userId = Math.round(Math.random() * 99999);
189143

0 commit comments

Comments
 (0)