diff --git a/component/OnlineStudy/2-PlayerPKHome/index.js b/component/OnlineStudy/2-PlayerPKHome/index.js index 7d46b4affdd55c9d2a16a91b219bc6efbfae5d32..18d183c104c98ebc33d7f392e6a95d885033b53f 100644 --- a/component/OnlineStudy/2-PlayerPKHome/index.js +++ b/component/OnlineStudy/2-PlayerPKHome/index.js @@ -47,6 +47,7 @@ class TwoPlayerPKHome extends Component { joinMatch = () => { this.setState({isStarted: true, isCanceling: false}); console.log('websocket 已打开'); + // console.log(websocket.get().readyState); websocket.joinMatch(); }; diff --git a/component/OnlineStudy/MyTest/index.js b/component/OnlineStudy/MyTest/index.js index 465b08c58612f003af7fd78dd66be19229787de0..ee8dbff2727c040ccf0eb57f2c1681a5b76fb88f 100644 --- a/component/OnlineStudy/MyTest/index.js +++ b/component/OnlineStudy/MyTest/index.js @@ -14,7 +14,7 @@ export function login() { const resolveData = data => { console.log(data); }; - console.log('[Login] sno: ' + data.sno + ' password: ' + data.password); + // console.log('[Login] sno: ' + data.sno + ' password: ' + data.password); post(URL_LOGIN, data).then(resolveData).catch(); } @@ -22,7 +22,7 @@ export function logout() { const resolveData = data => { console.log(data); }; - console.log('[Logout]'); + // console.log('[Logout]'); get(URL_LOGOUT, {}).then(resolveData).catch(); } diff --git a/component/OnlineStudy/MyUtilities/index.js b/component/OnlineStudy/MyUtilities/index.js index c3169eb167b9aed7d17a06548e45f1e9af59edd4..aabd9e2ba7116ad1f88128d9336aa5e1a5f85e68 100644 --- a/component/OnlineStudy/MyUtilities/index.js +++ b/component/OnlineStudy/MyUtilities/index.js @@ -87,55 +87,57 @@ export class websocket { static connect(functions) { const url = URL_2PLAYER_PK_MATCH + sno.get(); - console.log(`[url_2player_PK_match] ${url}`); - getCookies().then(cookies => { - console.log('[cookies] ', cookies); - let cookie = ''; - for (let key in cookies) { - cookie += `${cookies[key].name}=${cookies[key].value}&`; - } - cookie = cookie.substring(0, cookie.length - 1); - this.set( - new WebSocket(url, null, { - headers: { - cookie: cookie, - }, - }), - ); - //打开事件 - if (functions.hasOwnProperty('onopen')) { - this.get().onopen = functions.onopen; - } else { - this.get().onopen = function () { - console.log('websocket 已打开'); - }; - } - //获得消息事件 - if (functions.hasOwnProperty('onmessage')) { - this.get().onmessage = functions.onmessage; - } else { - this.get().onmessage = function (msg) { - const serverMsg = '收到服务端信息: ' + msg.data; - console.log(serverMsg); - }; - } - //关闭事件 - if (functions.hasOwnProperty('onclose')) { - this.get().onclose = functions.onclose; - } else { - this.get().onclose = function () { - console.log('websocket 已关闭'); - }; - } - //发生了错误事件 - if (functions.hasOwnProperty('onerror')) { - this.get().onerror = functions.onerror; - } else { - this.get().onerror = function () { - console.log('websocket 发生了错误'); - }; - } - }); + // console.log(`[url_2player_PK_match] ${url}`); + getCookies() + .then(cookies => { + // console.log('[cookies] ', cookies); + let cookie = ''; + for (let key in cookies) { + cookie += `${cookies[key].name}=${cookies[key].value}&`; + } + cookie = cookie.substring(0, cookie.length - 1); + this.set( + new WebSocket(url, null, { + headers: { + cookie: cookie, + }, + }), + ); + //打开事件 + if (functions.hasOwnProperty('onopen')) { + this.get().onopen = functions.onopen; + } else { + this.get().onopen = function () { + console.log('websocket 已打开'); + }; + } + //获得消息事件 + if (functions.hasOwnProperty('onmessage')) { + this.get().onmessage = functions.onmessage; + } else { + this.get().onmessage = function (msg) { + const serverMsg = '收到服务端信息: ' + msg.data; + console.log(serverMsg); + }; + } + //关闭事件 + if (functions.hasOwnProperty('onclose')) { + this.get().onclose = functions.onclose; + } else { + this.get().onclose = function () { + console.log('websocket 已关闭'); + }; + } + //发生了错误事件 + if (functions.hasOwnProperty('onerror')) { + this.get().onerror = functions.onerror; + } else { + this.get().onerror = function () { + console.log('websocket 发生了错误'); + }; + } + }) + .catch(); } //打开事件 @@ -332,7 +334,7 @@ export function post(url, data = {}) { async function getCookies() { return await CookieManager.get(URL_SHORT).then(res => { - console.log('CookieManager.get =>', res); + // console.log('CookieManager.get =>', res); return res; }); }