From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/ja/web/api/websocket/binarytype/index.html | 50 +++++++ .../ja/web/api/websocket/bufferedamount/index.html | 41 ++++++ files/ja/web/api/websocket/close/index.html | 58 ++++++++ files/ja/web/api/websocket/close_event/index.html | 80 +++++++++++ files/ja/web/api/websocket/error_event/index.html | 77 +++++++++++ files/ja/web/api/websocket/extensions/index.html | 41 ++++++ files/ja/web/api/websocket/index.html | 150 +++++++++++++++++++++ .../ja/web/api/websocket/message_event/index.html | 74 ++++++++++ files/ja/web/api/websocket/onclose/index.html | 37 +++++ files/ja/web/api/websocket/onerror/index.html | 61 +++++++++ files/ja/web/api/websocket/onmessage/index.html | 50 +++++++ files/ja/web/api/websocket/onopen/index.html | 50 +++++++ files/ja/web/api/websocket/open_event/index.html | 74 ++++++++++ files/ja/web/api/websocket/protocol/index.html | 41 ++++++ files/ja/web/api/websocket/readystate/index.html | 79 +++++++++++ files/ja/web/api/websocket/send/index.html | 71 ++++++++++ files/ja/web/api/websocket/url/index.html | 43 ++++++ files/ja/web/api/websocket/websocket/index.html | 56 ++++++++ 18 files changed, 1133 insertions(+) create mode 100644 files/ja/web/api/websocket/binarytype/index.html create mode 100644 files/ja/web/api/websocket/bufferedamount/index.html create mode 100644 files/ja/web/api/websocket/close/index.html create mode 100644 files/ja/web/api/websocket/close_event/index.html create mode 100644 files/ja/web/api/websocket/error_event/index.html create mode 100644 files/ja/web/api/websocket/extensions/index.html create mode 100644 files/ja/web/api/websocket/index.html create mode 100644 files/ja/web/api/websocket/message_event/index.html create mode 100644 files/ja/web/api/websocket/onclose/index.html create mode 100644 files/ja/web/api/websocket/onerror/index.html create mode 100644 files/ja/web/api/websocket/onmessage/index.html create mode 100644 files/ja/web/api/websocket/onopen/index.html create mode 100644 files/ja/web/api/websocket/open_event/index.html create mode 100644 files/ja/web/api/websocket/protocol/index.html create mode 100644 files/ja/web/api/websocket/readystate/index.html create mode 100644 files/ja/web/api/websocket/send/index.html create mode 100644 files/ja/web/api/websocket/url/index.html create mode 100644 files/ja/web/api/websocket/websocket/index.html (limited to 'files/ja/web/api/websocket') diff --git a/files/ja/web/api/websocket/binarytype/index.html b/files/ja/web/api/websocket/binarytype/index.html new file mode 100644 index 0000000000..d851b58608 --- /dev/null +++ b/files/ja/web/api/websocket/binarytype/index.html @@ -0,0 +1,50 @@ +--- +title: WebSocket.binaryType +slug: Web/API/WebSocket/binaryType +translation_of: Web/API/WebSocket/binaryType +--- +

{{APIRef("Web Sockets API")}}

+ +

WebSocket.binaryType は、コネクションによって送信されているバイナリデータの型を返すプロパティです。

+ +

構文

+ +
var binaryType = aWebSocket.binaryType;
+ +

+ +

{{DOMXref("DOMString")}}:

+ +
+
"blob"
+
{{domxref("Blob")}} オブジェクトが使われている場合
+
"arraybuffer"
+
{{jsxref("ArrayBuffer")}} オブジェクトが使われている場合 + +
+
+ +

仕様書

+ + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('HTML WHATWG', '#dom-websocket-binarytype', 'WebSocket: binaryType')}}{{Spec2('HTML WHATWG')}}初回定義
+ +

ブラウザ互換性

+ + + +

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

diff --git a/files/ja/web/api/websocket/bufferedamount/index.html b/files/ja/web/api/websocket/bufferedamount/index.html new file mode 100644 index 0000000000..1f74c94df2 --- /dev/null +++ b/files/ja/web/api/websocket/bufferedamount/index.html @@ -0,0 +1,41 @@ +--- +title: WebSocket.bufferedAmount +slug: Web/API/WebSocket/bufferedAmount +translation_of: Web/API/WebSocket/bufferedAmount +--- +

{{APIRef("Web Sockets API")}}

+ +

WebSocket.bufferedAmount は {{manch("send")}} の呼び出しによってキューに入れられてはいますが、まだネットワークに送信されていないデータのバイト数を返す読み取り専用のプロパティです。この値は、一度キューに入れられたデータすべてが送信されると 0 にリセットされます。なお、コネクションが閉じられたときは、 0 にリセットされません。{{manch("send")}} を呼び出し続けると、この値は大きくなっていきます。

+ +

構文

+ +
var bufferedAmount = aWebSocket.bufferedAmount;
+ +

+ +

符号なしのロング型

+ +

仕様書

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#dom-websocket-bufferedamount', 'WebSocket: bufferedAmount')}}{{Spec2('HTML WHATWG')}}Initial definition
+ +

ブラウザ互換性

+ + + +

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

diff --git a/files/ja/web/api/websocket/close/index.html b/files/ja/web/api/websocket/close/index.html new file mode 100644 index 0000000000..e81076b85a --- /dev/null +++ b/files/ja/web/api/websocket/close/index.html @@ -0,0 +1,58 @@ +--- +title: WebSocket.close() +slug: Web/API/WebSocket/close +translation_of: Web/API/WebSocket/close +--- +

{{APIRef("Web Sockets API")}}

+ +

WebSocket.close() メソッドは、{{domxref("WebSocket")}} の接続、もしくは接続試行(存在した場合)を閉じます。接続がすでに CLOSED だった場合、このメソッドは何もしません。

+ +

構文

+ +
WebSocket.close();
+ +

引数

+ +
+
code {{optional_inline}}
+
接続が閉じられている理由を説明するためのステータスコードを示す数値を指定します。このパラメータを指定しない場合、デフォルト値として 1005 が指定されます。許可されている値については{{domxref("CloseEvent")}}のステータスコードの一覧を参照してください。
+
reason {{optional_inline}}
+
接続が閉じられている理由を説明するための人間が読める文字列を指定します。この文字列は UTF-8 テキスト (文字ではありません) で 123 バイトを超えていけません。
+
+ +

投げられる例外

+ +
+
INVALID_ACCESS_ERR
+
無効な code が指定された場合
+
SYNTAX_ERR
+
reason に指定した文字列が長すぎるか、ペアリングされていないサロゲートを含んでいる場合
+
+ +
+

注意: Gecko において、Gecko 8.0 {{geckoRelease("8.0")}} 以前は、このメソッドはいづれのパラメータもサポートしていませんでした。

+
+ +

仕様書

+ + + + + + + + + + + + + + +
仕様書状態備考
HTML Living Standard
+ The definition of 'WebSocket.close()' in that specification.
Living Standard初回定義
+ +

ブラウザの互換性

+ + + +

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

diff --git a/files/ja/web/api/websocket/close_event/index.html b/files/ja/web/api/websocket/close_event/index.html new file mode 100644 index 0000000000..136ceea555 --- /dev/null +++ b/files/ja/web/api/websocket/close_event/index.html @@ -0,0 +1,80 @@ +--- +title: 'WebSocket: close イベント' +slug: Web/API/WebSocket/close_event +tags: + - Reference + - Web + - WebSocket + - close + - events + - イベント +translation_of: Web/API/WebSocket/close_event +--- +
{{APIRef}}
+ +

close イベントは、 WebSocket のコネクションが閉じられたときに発生します。

+ + + + + + + + + + + + + + + + + + + + +
バブリングなし
キャンセル不可
インターフェイス{{domxref("Event")}}
イベントハンドラープロパティ{{ domxref("WebSocket.onclose","onclose")}}
+ +

+ +

コネクションが閉じられる時が分かれば、 UI を更新させたり、閉じたコネクションについてのデータを保存したりすることができます。以下の例では exampleSocket と呼ばれる変数が開かれた WebSocket を参照しており、このハンドラーが、ソケットが閉じられた場面を扱います。

+ +
exampleSocket.addEventListener('close', (event) => {
+  console.log('The connection has been closed successfully.');
+)};
+ +

同じことを、イベントハンドラープロパティを用いて行うこともできます。

+ +
exampleSocket.onclose = function (event) {
+  console.log('The connection has been closed successfully.');
+};
+ +

仕様書

+ + + + + + + + + + + + + + +
仕様書状態
{{SpecName("HTML WHATWG", "web-sockets.html#event-close", "WebSocket close")}}{{Spec2("HTML WHATWG")}}
+ +

ブラウザーの互換性

+ +

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

+ +

関連情報

+ + diff --git a/files/ja/web/api/websocket/error_event/index.html b/files/ja/web/api/websocket/error_event/index.html new file mode 100644 index 0000000000..e833c7fdcf --- /dev/null +++ b/files/ja/web/api/websocket/error_event/index.html @@ -0,0 +1,77 @@ +--- +title: 'WebSocket: error イベント' +slug: Web/API/WebSocket/error_event +tags: + - API + - Error + - Event + - Reference + - Web + - WebSocket + - イベント +translation_of: Web/API/WebSocket/error_event +--- +
{{APIRef}}
+ +

error イベントは、 WebSocket のコネクションがエラーによって閉じられた (例えば一部のデータを送信できなかった) ときに発生します。

+ + + + + + + + + + + + + + + + + + + + +
バブリングなし
キャンセル不可
インターフェイス{{domxref("Event")}}
イベントハンドラープロパティ{{ domxref("WebSocket.onerror","onerror")}}
+ +

+ +
// Create WebSocket connection
+const socket = new WebSocket('ws://localhost:8080');
+
+// Listen for possible errors
+socket.addEventListener('error', function (event) {
+  console.log('WebSocket error: ', event);
+});
+ +

仕様書

+ + + + + + + + + + + + + + +
仕様書状態
{{SpecName("HTML WHATWG", "web-sockets.html#event-open", "WebSocket open")}}{{Spec2("HTML WHATWG")}}
+ +

ブラウザーの互換性

+ +

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

+ +

関連情報

+ + diff --git a/files/ja/web/api/websocket/extensions/index.html b/files/ja/web/api/websocket/extensions/index.html new file mode 100644 index 0000000000..38a9035de6 --- /dev/null +++ b/files/ja/web/api/websocket/extensions/index.html @@ -0,0 +1,41 @@ +--- +title: WebSocket.extensions +slug: Web/API/WebSocket/extensions +translation_of: Web/API/WebSocket/extensions +--- +

{{APIRef("Web Sockets API")}}

+ +

WebSocket.extensions は、サーバーによって選択された拡張機能を返す読み取り専用のプロパティです。現在は、空の文字列か、接続によってネゴシエートされた拡張機能のリストのみを返します。

+ +

構文

+ +
var extensions = aWebSocket.extensions;
+ +

+ +

{{domxref("DOMString")}}

+ +

仕様書

+ + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('HTML WHATWG', '#dom-websocket-extensions', 'WebSocket: extensions')}}{{Spec2('HTML WHATWG')}}初回定義
+ +

ブラウザ互換性

+ + + +

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

diff --git a/files/ja/web/api/websocket/index.html b/files/ja/web/api/websocket/index.html new file mode 100644 index 0000000000..cf61c05a16 --- /dev/null +++ b/files/ja/web/api/websocket/index.html @@ -0,0 +1,150 @@ +--- +title: WebSocket +slug: Web/API/WebSocket +tags: + - API + - Interface + - NeedsContent + - WebSocket + - WebSockets + - インターフェイス +translation_of: Web/API/WebSocket +--- +
{{APIRef("Web Sockets API")}}
+ +

WebSocket オブジェクトは、サーバーへの WebSocket 接続の作成と管理、および接続上のデータの送受信に使用する API を提供します。

+ +

WebSocket を構築するには、 WebSocket() コンストラクターを使用してください。

+ +

コンストラクター

+ +
+
{{domxref("WebSocket.WebSocket", "WebSocket(url[, protocols])")}}
+
新しく作成された WebSocket オブジェクトを返します。
+
+ +

定数

+ + + + + + + + + + + + + + + + + + + + + + + + +
定数
WebSocket.CONNECTING0
WebSocket.OPEN1
WebSocket.CLOSING2
WebSocket.CLOSED3
+ +

プロパティ

+ +
+
{{domxref("WebSocket.binaryType")}}
+
接続で使用されるバイナリデータ型。
+
{{domxref("WebSocket.bufferedAmount")}} {{readonlyinline}}
+
キューに入れられたデータのバイト数。
+
{{domxref("WebSocket.extensions")}} {{readonlyinline}}
+
サーバーによって選択された拡張機能。
+
{{domxref("WebSocket.onclose")}}
+
接続が閉じられたときに呼び出されるイベントリスナー。
+
{{domxref("WebSocket.onerror")}}
+
エラーが発生したときに呼び出されるイベントリスナー。
+
{{domxref("WebSocket.onmessage")}}
+
サーバーからメッセージを受信したときに呼び出されるイベントリスナー。
+
{{domxref("WebSocket.onopen")}}
+
接続が開かれたときに呼び出されるイベントリスナー。
+
{{domxref("WebSocket.protocol")}} {{readonlyinline}}
+
サーバーによって選択されたサブプロトコル。
+
{{domxref("WebSocket.readyState")}} {{readonlyinline}}
+
接続の現在の状態。
+
{{domxref("WebSocket.url")}} {{readonlyinline}}
+
WebSocket の絶対 URL。
+
+ +

メソッド

+ +
+
{{domxref("WebSocket.close", "WebSocket.close([code[, reason]])")}}
+
接続を閉じます。
+
{{domxref("WebSocket.send", "WebSocket.send(data)")}}
+
送信するデータをキューに入れます。
+
+ +

イベント

+ +

これらのイベントを待ち受けするには、 addEventListener() を使用するか、イベントリスナーをこのインターフェイスの oneventname プロパティへ代入します。

+ +
+
{{domxref("WebSocket/close_event", "close")}}
+
WebSocket による接続が閉じたときに発生します。
+ {{domxref("WebSocket/onclose", "onclose")}} プロパティからも利用できます。
+
{{domxref("WebSocket/error_event", "error")}}
+
WebSocket による接続が、データの一部が送信できなかったなどのエラーのために閉じた時に発生します。
+ {{domxref("WebSocket/onerror", "onerror")}} プロパティからも利用できます。
+
{{domxref("WebSocket/message_event", "message")}}
+
WebSocket を通じてデータを受信したときに発生します。
+ {{domxref("WebSocket/onmessage", "onmessage")}} プロパティからも利用できます。
+
{{domxref("WebSocket/open_event", "open")}}
+
WebSocket による接続が開いたときに発生します。
+ {{domxref("WebSocket/onopen", "onopen")}} プロパティからも利用できます。
+
+ +

+ +
// WebSocket 接続を作成
+const socket = new WebSocket('ws://localhost:8080');
+
+// 接続が開いたときのイベント
+socket.addEventListener('open', function (event) {
+    socket.send('Hello Server!');
+});
+
+// メッセージの待ち受け
+socket.addEventListener('message', function (event) {
+    console.log('Message from server ', event.data);
+});
+ +

仕様書

+ + + + + + + + + + + + + + +
仕様書状態
{{SpecName("HTML WHATWG", "#network", "WebSocket")}}{{Spec2("HTML WHATWG")}}
+ +

ブラウザーの互換性

+ +
+ + +

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

+
+ +

関連情報

+ + diff --git a/files/ja/web/api/websocket/message_event/index.html b/files/ja/web/api/websocket/message_event/index.html new file mode 100644 index 0000000000..c268e079c0 --- /dev/null +++ b/files/ja/web/api/websocket/message_event/index.html @@ -0,0 +1,74 @@ +--- +title: 'WebSocket: message イベント' +slug: Web/API/WebSocket/message_event +tags: + - Event + - Reference + - WebSocket + - message +translation_of: Web/API/WebSocket/message_event +--- +
{{APIRef}}
+ +

message ハンドラーは、 WebSocket を通してデータを受け取ったときに発生します。

+ + + + + + + + + + + + + + + + + + + + +
バブリングなし
キャンセル不可
インターフェイス{{domxref("MessageEvent")}}
イベントハンドラープロパティ{{ domxref("WebSocket.onmessage","onmessage")}}
+ +

+ +
// Create WebSocket connection.
+const socket = new WebSocket('ws://localhost:8080');
+
+// Listen for messages
+socket.addEventListener('message', function (event) {
+    console.log('Message from server ', event.data);
+});
+ +

仕様書

+ + + + + + + + + + + + + + +
仕様書状態
{{SpecName("HTML WHATWG", "web-sockets.html#event-message", "WebSocket message")}}{{Spec2("HTML WHATWG")}}
+ +

ブラウザーの互換性

+ +

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

+ +

関連情報

+ + diff --git a/files/ja/web/api/websocket/onclose/index.html b/files/ja/web/api/websocket/onclose/index.html new file mode 100644 index 0000000000..311998e44c --- /dev/null +++ b/files/ja/web/api/websocket/onclose/index.html @@ -0,0 +1,37 @@ +--- +title: WebSocket.onclose +slug: Web/API/WebSocket/onclose +translation_of: Web/API/WebSocket/onclose +--- +

{{APIRef("Web Sockets API")}}

+ +

WebSocket.onclose プロパティは、WebSocket コネクションの {{domxref("WebSocket.readyState","readyState")}} が {{domxref("WebSocket.readyState","CLOSED")}} に変わったときに呼ばれる {{domxref("EventHandler")}} です。{{domxref("CloseEvent")}} と一緒に呼び出されます。

+ +

構文

+ +
aWebSocket.onclose = function(event) {
+  console.log("WebSocket is closed now.");
+};
+ +

+ +

{{domxref("EventListener")}}.

+ +

仕様書

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#handler-websocket-onclose', 'WebSocket: onclose')}}{{Spec2('HTML WHATWG')}}Initial definition
diff --git a/files/ja/web/api/websocket/onerror/index.html b/files/ja/web/api/websocket/onerror/index.html new file mode 100644 index 0000000000..717a0ae735 --- /dev/null +++ b/files/ja/web/api/websocket/onerror/index.html @@ -0,0 +1,61 @@ +--- +title: WebSocket.onerror +slug: Web/API/WebSocket/onerror +tags: + - API + - Connection + - Error + - Error Handler + - Networking + - Property + - Reference + - Web API + - WebSocket + - onerror + - プロパティ +translation_of: Web/API/WebSocket/onerror +--- +
{{APIRef("Web Sockets API")}}
+ +

{{domxref("WebSocket")}} インターフェイスの onerror イベントハンドラープロパティは、 WebSocket でエラーが発生したときに呼び出される関数です。

+ +

error イベントハンドラーは {{domxref("EventTarget.addEventListener", "addEventListener()")}} で追加することもできます。

+ +

構文

+ +
webSocket.onerror = eventHandler;
+ +

+ +

関数または {{domxref("EventHandler")}} で、 WebSocket コネクションで error イベントが発生するたびに呼び出されるものです。

+ +

+ +
webSocket.onerror = function(event) {
+  console.error("WebSocket error observed:", event);
+};
+ +

仕様書

+ + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('HTML WHATWG', '#handler-websocket-onerror', 'WebSocket: onerror')}}{{Spec2('HTML WHATWG')}}初回定義
+ +

ブラウザーの互換性

+ + + +

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

diff --git a/files/ja/web/api/websocket/onmessage/index.html b/files/ja/web/api/websocket/onmessage/index.html new file mode 100644 index 0000000000..fc69900854 --- /dev/null +++ b/files/ja/web/api/websocket/onmessage/index.html @@ -0,0 +1,50 @@ +--- +title: WebSocket.onmessage +slug: Web/API/WebSocket/onmessage +tags: + - API + - Property + - Reference + - Web API + - WebSocket + - プロパティ +translation_of: Web/API/WebSocket/onmessage +--- +
{{APIRef("Web Sockets API")}}
+ +

WebSocket.onmessage プロパティは、サーバーからメッセージが届いたときに呼び出されるイベントハンドラー ({{domxref("EventHandler")}}) です。これは {{domxref("MessageEvent")}} で呼び出されます。

+ +

構文

+ +
aWebSocket.onmessage = function(event) {
+  console.debug("WebSocket message received:", event);
+};
+ +

+ +

{{domxref("EventListener")}} です。

+ +

仕様書

+ + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('HTML WHATWG', '#handler-websocket-onmessage', 'WebSocket: onmessage')}}{{Spec2('HTML WHATWG')}}初回定義
+ +

ブラウザーの互換性

+ + + +

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

diff --git a/files/ja/web/api/websocket/onopen/index.html b/files/ja/web/api/websocket/onopen/index.html new file mode 100644 index 0000000000..cf8006465e --- /dev/null +++ b/files/ja/web/api/websocket/onopen/index.html @@ -0,0 +1,50 @@ +--- +title: WebSocket.onopen +slug: Web/API/WebSocket/onopen +tags: + - API + - Property + - Reference + - Web API + - WebSocket + - プロパティ +translation_of: Web/API/WebSocket/onopen +--- +
{{APIRef("Web Sockets API")}}
+ +

WebSocket.onopen プロパティはイベントハンドラー ({{domxref("EventHandler")}}) で、 {{domxref("WebSocket")}} のコネクションの {{domxref("WebSocket.readyState","readyState")}} が {{domxref("WebSocket.readyState","1")}} に変化したときに呼び出されます。これは、コネクションでデータを送信したり受信したりする準備ができたことを示します。これは {{domxref("Event")}} を伴って呼び出されます。

+ +

構文

+ +
aWebSocket.onopen = function(event) {
+  console.log("WebSocket is open now.");
+};
+ +

+ +

{{domxref("EventListener")}} です。

+ +

仕様書

+ + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('HTML WHATWG', '#handler-websocket-onopen', 'WebSocket: onopen')}}{{Spec2('HTML WHATWG')}}初回定義
+ +

ブラウザーの互換性

+ + + +

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

diff --git a/files/ja/web/api/websocket/open_event/index.html b/files/ja/web/api/websocket/open_event/index.html new file mode 100644 index 0000000000..9f2780b504 --- /dev/null +++ b/files/ja/web/api/websocket/open_event/index.html @@ -0,0 +1,74 @@ +--- +title: 'WebSocket: open イベント' +slug: Web/API/WebSocket/open_event +tags: + - API + - WebSocket + - events + - open +translation_of: Web/API/WebSocket/open_event +--- +
{{APIRef}}
+ +

open イベントは、 WebSocket のコネクションが開かれたときに発生します。

+ + + + + + + + + + + + + + + + + + + + +
バブリングなし
キャンセル不可
インターフェイス{{domxref("Event")}}
イベントハンドラープロパティ{{ domxref("WebSocket.onopen","onopen")}}
+ +

+ +
// Create WebSocket connection.
+const socket = new WebSocket('ws://localhost:8080');
+
+// Connection opened
+socket.addEventListener('open', (event) => {
+  socket.send('Hello Server!');
+});
+ +

仕様書

+ + + + + + + + + + + + + + +
仕様書状態
{{SpecName("HTML WHATWG", "web-sockets.html#event-open", "WebSocket open")}}{{Spec2("HTML WHATWG")}}
+ +

ブラウザーの互換性

+ +

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

+ +

関連情報

+ + diff --git a/files/ja/web/api/websocket/protocol/index.html b/files/ja/web/api/websocket/protocol/index.html new file mode 100644 index 0000000000..542e7247a0 --- /dev/null +++ b/files/ja/web/api/websocket/protocol/index.html @@ -0,0 +1,41 @@ +--- +title: WebSocket.protocol +slug: Web/API/WebSocket/protocol +translation_of: Web/API/WebSocket/protocol +--- +

{{APIRef("Web Sockets API")}}

+ +

WebSocket.protocol は、サーバーが選択したサブプロトコル名を返す読み取り専用のプロパティです。これは {{domxref("WebSocket")}} オブジェクトが作成されるときに、引数の protocols で指定された文字列のいづれかになりますが、もし接続が確立されていない場合は、空の文字列となります。

+ +

構文

+ +
var protocol = aWebSocket.protocol;
+ +

+ +

DOMString

+ +

仕様書

+ + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('HTML WHATWG', '#dom-websocket-protocol', 'WebSocket: protocol')}}{{Spec2('HTML WHATWG')}}初回定義
+ +

ブラウザ互換性

+ + + +

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

diff --git a/files/ja/web/api/websocket/readystate/index.html b/files/ja/web/api/websocket/readystate/index.html new file mode 100644 index 0000000000..82f6db18e9 --- /dev/null +++ b/files/ja/web/api/websocket/readystate/index.html @@ -0,0 +1,79 @@ +--- +title: WebSocket.readyState +slug: Web/API/WebSocket/readyState +translation_of: Web/API/WebSocket/readyState +--- +

{{APIRef("Web Sockets API")}}

+ +

WebSocket.readyState は、{{domxref("WebSocket")}} の「現在」の接続状態を返す読み取り専用のプロパティです。

+ +

構文

+ +
var readyState = aWebSocket.readyState;
+ +

+ +

以下のいづれかの 符号なしショート型 の値を返します。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ValueStateDescription
0CONNECTING +

ソケットは作成されているが、まだコネクションが開いていない状態

+
1OPEN +

コネクションが開き、通信の準備ができている状態

+
2CLOSING +

コネクションが閉じる過程にある状態

+
3CLOSED +

コネクションが閉じられたか、もしくは開けていなかった状態

+
+ +

仕様書

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#dom-websocket-readystate', 'WebSocket: readyState')}}{{Spec2('HTML WHATWG')}}Initial definition
+ +

ブラウザの互換性

+ + + +

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

diff --git a/files/ja/web/api/websocket/send/index.html b/files/ja/web/api/websocket/send/index.html new file mode 100644 index 0000000000..a2f17d7c36 --- /dev/null +++ b/files/ja/web/api/websocket/send/index.html @@ -0,0 +1,71 @@ +--- +title: WebSocket.send() +slug: Web/API/WebSocket/send +translation_of: Web/API/WebSocket/send +--- +

{{APIRef("Web Sockets API")}}

+ +

WebSocket.send() は WebSocket 接続を介してサーバーに送るために指定されたデータを、格納するために必要なバイト数だけ bufferedAmount の値を増加させながら、キューに入れるメソッドです。もしデータが送信できなかった場合(例えば、バッファリングが必要ですが、バッファが一杯であるなどの理由で)、ソケットは自動的に閉じられます。

+ +

構文

+ +
WebSocket.send("Hello server!");
+ +

引数

+ +
+
data
+
サーバーに送信するデータです。以下のいづれかのタイプのデータを指定します。
+
+
+
{{domxref("USVString")}}
+
テキスト文字列。文字列は、UTF-8 形式でバッファに追加され、bufferedAmount の値は UTF-8 の文字列を表すのに必要とされるバイト数だけ増えます。
+
{{domxref("ArrayBuffer")}}
+
型付きの配列オブジェクトで使用される基本的なバイナリデータを送信することができます。このバイナリデータのコンテンツは,必要なバイト数だけ bufferedAmount の値を増やして、バッファのキューに入れられます。
+
{{domxref("Blob")}}
+
Blob を指定すると、バイナリフレームで送信される blob の生データをキューに入れます。bufferedAmount の値は、その生データのバイトサイズだけ増えます。
+
{{domxref("ArrayBufferView")}}
+
JavaScriptで型付けされた配列オブジェクトをバイナリフレームとして送信することができます。このバイナリデータのコンテンツは,必要なバイト数だけ bufferedAmount の値を増やして、バッファのキューに入れられます。
+
+
+
+ +

投げられる例外

+ +
+
INVALID_STATE_ERR
+
接続が OPEN になっていない場合
+
SYNTAX_ERR
+
データが、ペアリングされていないサロゲートを持つ文字列の場合
+
+ +
+

注意: Gecko の send() メソッドの実装は、{{Gecko("6.0")}} の仕様とは多少異なります。 Geckoは、接続がまだ開いているかどうか(さらに、extension によって、データが正常にキューに入れられたか、もしくは送信されたかどうか)を示す boolean を返します。これは {{Gecko("8.0")}} で修正されています。

+ +

{{Gecko("11.0")}} では、{{jsxref("ArrayBuffer")}} のサポートは実装されていますが、{{domxref("Blob")}} データ型はサポートされていません。

+
+ +

仕様書

+ + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('HTML WHATWG', '#dom-websocket-send', 'WebSocket: send')}}{{Spec2('HTML WHATWG')}}初回定義
+ +

ブラウザ互換性

+ + + +

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

diff --git a/files/ja/web/api/websocket/url/index.html b/files/ja/web/api/websocket/url/index.html new file mode 100644 index 0000000000..4fec72f012 --- /dev/null +++ b/files/ja/web/api/websocket/url/index.html @@ -0,0 +1,43 @@ +--- +title: WebSocket.url +slug: Web/API/WebSocket/url +translation_of: Web/API/WebSocket/url +--- +

{{APIRef("Web Sockets API")}}

+ +

WebSocket.url は、コンストラクタによって解決された {{domxref("WebSocket")}} の絶対 URL を返す読み取り専用のプロパティです。

+ +

構文

+ +
var url = aWebSocket.url;
+ + + +

+ +

DOMString

+ +

仕様書

+ + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('HTML WHATWG', '#dom-websocket-url', 'WebSocket: url')}}{{Spec2('HTML WHATWG')}}初回定義
+ +

ブラウザ互換性

+ + + +

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

diff --git a/files/ja/web/api/websocket/websocket/index.html b/files/ja/web/api/websocket/websocket/index.html new file mode 100644 index 0000000000..77289d22ba --- /dev/null +++ b/files/ja/web/api/websocket/websocket/index.html @@ -0,0 +1,56 @@ +--- +title: WebSocket() +slug: Web/API/WebSocket/WebSocket +translation_of: Web/API/WebSocket/WebSocket +--- +

{{APIRef("Web Sockets API")}}

+ +

WebSocket() コンストラクタは新しい{{domxref("WebSocket")}} オブジェクトを返します。

+ +

構文

+ +
var aWebSocket = new WebSocket(url [, protocols]);
+ +

引数

+ +
+
url
+
接続先のURL。WebSocketサーバが応答するURLでなければならない。
+
protocols {{optional_inline}}
+
プロトコル文字列ひとつもしくはその配列。サーバは複数のWebSocketサブプロトコルを実装することもでき、その文字列はサブプロトコルを指定するために使われる(例えば、一つのサーバが指定されたprotocolに応じて異なるタイプのやりとりを扱うようにしたい場合)。プロトコル文字列を指定しない場合は空文字列と見なされる。
+
+ +

投げられる例外

+ +
+
SECURITY_ERR
+
接続が試みられているポートがブロックされている場合
+
+ +
+
SyntaxError
+
URLが無効だった場合
+
+ +

仕様書

+ + + + + + + + + + + + + + +
仕様書状況コメント
{{SpecName('HTML WHATWG', '#dom-websocket', 'the WebSocket constructor')}}{{Spec2('HTML WHATWG')}}
+ +

ブラウザ互換性

+ + + +

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

-- cgit v1.2.3-54-g00ecf