From 218934fa2ed1c702a6d3923d2aa2cc6b43c48684 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:43:23 -0500 Subject: initial commit --- files/tr/web/api/websocket/index.html | 138 ++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 files/tr/web/api/websocket/index.html (limited to 'files/tr/web/api/websocket/index.html') diff --git a/files/tr/web/api/websocket/index.html b/files/tr/web/api/websocket/index.html new file mode 100644 index 0000000000..ce8a030def --- /dev/null +++ b/files/tr/web/api/websocket/index.html @@ -0,0 +1,138 @@ +--- +title: WebSocket +slug: Web/API/WebSocket +tags: + - API + - WebSocket + - WebSockets +translation_of: Web/API/WebSocket +--- +
{{APIRef("Web Sockets API")}}
+ +

WebSocket, bir WebSocket sunucusuyla bağlantı kurmak ve bağlantıyı yönetmek için bir uygulama programlama arayüzü (API) sunar.

+ +

WebSocket'i kurmak için WebSocket() yapısını kullanın.

+ +

Yapılar

+ +
+
{{domxref("WebSocket.WebSocket", "WebSocket(url[, protocols])")}}
+
Yeni oluşturulmuş bir WebSocket objesi verir.
+
+ +

Sabitler

+ + + + + + + + + + + + + + + + + + + + + + + + +
SabitDeğer
WebSocket.CONNECTING0
WebSocket.OPEN1
WebSocket.CLOSING2
WebSocket.CLOSED3
+ +

Özellikler

+ +
+
{{domxref("WebSocket.binaryType")}}
+
Bağlantıda kurulan ikilik veri tipi.
+
{{domxref("WebSocket.bufferedAmount")}} {{readonlyinline}}
+
Kuyruktaki değerlerin byte sayıları.
+
{{domxref("WebSocket.extensions")}} {{readonlyinline}}
+
Sunucu tarafından seçilmiş uzantılar.
+
{{domxref("WebSocket.onclose")}}
+
Bağlantı kapandığında çağırılan olay dinleyicisi.
+
{{domxref("WebSocket.onerror")}}
+
Hata oluştuğunda çağırılan olay dinleyicisi.
+
{{domxref("WebSocket.onmessage")}}
+
Sunucudan mesaj alındığında çağırılan olay dinleyicisi.
+
{{domxref("WebSocket.onopen")}}
+
Bağlantı kurulduğunda çağırılan olay dinleyicisi.
+
{{domxref("WebSocket.protocol")}} {{readonlyinline}}
+
Sunucu tarafından seçilmiş alt-protokol.
+
{{domxref("WebSocket.readyState")}} {{readonlyinline}}
+
Bağlantının şimdiki durumu.
+
{{domxref("WebSocket.url")}} {{readonlyinline}}
+
WebSocket'in mutlak URL'si.
+
+ +

Yöntemler

+ +
+
{{domxref("WebSocket.close", "WebSocket.close([code[, reason]])")}}
+
Bağlantıyı kapatır.
+
{{domxref("WebSocket.send", "WebSocket.send(data)")}}
+
İletilmek üzere veriyi kuyruğa ekler.
+
+ +

Örnek

+ +

 

+ +
// WebSocket bağlantısı kur
+const socket = new WebSocket('ws://localhost:8080');
+
+// Bağlantı kurulduğunda
+socket.addEventListener('open', function (event) {
+    socket.send('Sunucuya bağlanıldı.');
+});
+
+// Mesaj alındığında
+socket.addEventListener('message', function (event) {
+    console.log('Mesaj alındı: ', event.data);
+});
+
+// Mesaj gönder
+socket.send('Merhaba!');
+
+// Bağlantıyı bitir
+socket.close(1000, 'Güle güle.');
+ +

 

+ +

Belirtimler

+ + + + + + + + + + + + + + +
BelirtimDurumYorum
{{SpecName("HTML WHATWG", "web-sockets.html#the-websocket-interface", "WebSocket")}}{{Spec2("HTML WHATWG")}}İlk tanım
+ +

Tarayıcı desteği

+ +
+ + +

{{Compat("api.WebSocket")}}

+
+ +

Ayrıca bakınız

+ + -- cgit v1.2.3-54-g00ecf