Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
M
mangala-pardusacikhack
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Tuğba Fıçıcı
mangala-pardusacikhack
Commits
65f45a27
Kaydet (Commit)
65f45a27
authored
May 05, 2021
tarafından
Abdülkerim AKSAK
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
odadan ayrilma eklendi
odaya katılma ve oda olusturma fonksiyon hataları giderildi
üst
d393a461
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
5 deletions
+48
-5
clientApp.js
pages/clientApp.js
+30
-0
server.js
socketIOServer/server.js
+18
-5
No files found.
pages/clientApp.js
Dosyayı görüntüle @
65f45a27
...
...
@@ -39,3 +39,33 @@ odaOlusturBtn.onclick = () => {
});
odaOlusturContainer
.
appendChild
(
elemt3
);
};
// ODAYA KATIL
const
odayaKatilContainer
=
document
.
getElementById
(
"odayaKatil"
);
const
odayaKatilBtn
=
document
.
getElementById
(
"odayaKatilBtn"
);
const
odayaKatilInput
=
document
.
getElementById
(
"odayaKatilInput"
);
odayaKatilBtn
.
onclick
=
()
=>
{
let
roomKey
=
odayaKatilInput
.
value
;
game
.
emit
(
"joinRoom"
,
roomKey
,
"Muaz"
);
//username dinamik olmalı!
let
elemt
=
document
.
createElement
(
"p"
);
game
.
on
(
"success"
,
(
roomKey
)
=>
{
elemt
.
textContent
=
roomKey
+
" odasına giriş yapıldı."
;
});
game
.
on
(
"err"
,
(
roomKey
)
=>
{
elemt
.
textContent
=
roomKey
+
" odasına giriş yapılamadı."
;
});
odayaKatilContainer
.
appendChild
(
elemt
);
};
// ODADAN AYRIL
const
odadanAyrilBtn
=
document
.
getElementById
(
"odadanAyrilBtn"
);
odadanAyrilBtn
.
onclick
=
()
=>
{
let
roomKey
=
odayaKatilInput
.
value
;
game
.
emit
(
"disconnection"
,
roomKey
);
let
elemt
=
document
.
createElement
(
"p"
);
game
.
on
(
"disconnectionRoom"
,
(
key
)
=>
{
elemt
.
textContent
=
key
+
" odasından ayrıldın."
;
});
odayaKatilContainer
.
appendChild
(
elemt
);
};
socketIOServer/server.js
Dosyayı görüntüle @
65f45a27
...
...
@@ -14,7 +14,7 @@ io.of("/game").on("connection", (socket) => {
// Oda Oluşturma
socket
.
on
(
"odaOlustur"
,
function
(
roomKey
)
{
gameRooms
.
push
(
roomKey
);
//oda için oluşturulan key
console
.
log
(
`"
${
roomKey
}
" odasi olusturuldu.`
);
console
.
log
(
`
odaOlustur..:
"
${
roomKey
}
" odasi olusturuldu.`
);
return
socket
.
emit
(
"odaBasariliSekildeOlusturuldu"
,
roomKey
);
});
...
...
@@ -22,14 +22,27 @@ io.of("/game").on("connection", (socket) => {
socket
.
on
(
"joinRoom"
,
(
roomKey
,
username
)
=>
{
if
(
gameRooms
.
includes
(
roomKey
))
{
socket
.
join
(
roomKey
);
io
.
of
(
"/
chat
"
).
in
(
roomKey
).
emit
(
"newUser"
,
username
);
//odaya biri girdiğinde tetiklenir
console
.
log
(
`"
${
roomKey
}
" odasina "
${
username
}
giris yapti.`
);
return
socket
.
emit
(
"success"
,
roomKey
);
//eğer gameRooms içinde oda varsa (1)
io
.
of
(
"/
game
"
).
in
(
roomKey
).
emit
(
"newUser"
,
username
);
//odaya biri girdiğinde tetiklenir
console
.
log
(
`
joinRoom..:
"
${
roomKey
}
" odasina "
${
username
}
giris yapti.`
);
return
socket
.
emit
(
"success"
,
roomKey
);
}
else
{
console
.
log
(
`"
${
roomKey
}
" odasina "
${
username
}
" giris yapilamadi.`
);
console
.
log
(
`joinRoom..: "
${
roomKey
}
" odasina "
${
username
}
" giris yaptilamadi.`
);
return
socket
.
emit
(
"err"
,
roomKey
);
}
});
// Odadan ayrılma
//? username
socket
.
on
(
"disconnection"
,
(
roomKey
)
=>
{
console
.
log
(
`disconnection...: "
${
roomKey
}
" odasindan ayrildi.`
);
let
index
=
gameRooms
.
indexOf
(
roomKey
);
//roomKey'e ait index değeri
if
(
index
>
-
1
)
{
gameRooms
.
splice
(
index
,
1
);
// odadan ayrilma gerceklestiginde oda silinir
}
return
socket
.
emit
(
"disconnectionRoom"
,
roomKey
);
});
});
http
.
listen
(
port
,
()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment