進入本網頁後,首先按F12。
然後會看到console呈現:
Uncaught InvalidStateError: Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.
參考本部分:
https://blog.csdn.net/benben_2015/article/details/79294547
藉由websocket.readyState呈現連接狀態\|/20251112D、\|/20251112E
CONNECTING:值为0,表示正在连接;
OPEN:值为1,表示连接成功,可以通信了;
CLOSING:值为2,表示连接正在关闭;
CLOSED:值为3,表示连接已经关闭,或者打开连接失败。
尚未傳遞信息前\|/20251112E:websocket.readyState=0
****傳遞信息過程中:
所傳出的信息已經鎖定為常數值\|/20251112H
●不能使用\|/20251112C直接執行程式的方式來傳出信息,會使得websocket.readyState=0
●必須使用按按鈕\|/20251112G 或 按Enter\|/20251112F 的方式來傳出信息
---------------------------------------------------------------------------
操作方式:
★於cmd執行下列:
cd 至程式路徑
★於cmd執行下列:
php zz_code_constChat_serverWilly2.php
****
藉由notepad2開啟
zz_code_constChat_clientWilly2.php
以及
zz_code_constChat_clientWilly2_onlycanreceivemessageWhenOtherBrowserSendMessage.php
^將當中的ws://192.168.3.188:9001改成伺服器ip,
譬如伺服器ip=192.168.3.123,則改成ws://192.168.3.123:9001
****
再藉由瀏覽器觀看:
http://127.0.0.1:8888/PHP_websocket_Willy/zz_code_constChat_clientWilly2.php
^點擊按鈕or按Enter,可傳出信息
http://127.0.0.1:8888/PHP_websocket_Willy/zz_code_constChat_clientWilly2_onlycanreceivemessageWhenOtherBrowserSendMessage.php
^可接收信息