Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
软件工程实践2022年春W班
穿梭在银河的火箭队
FZUStudyRoom
提交
b15524bf
F
FZUStudyRoom
项目概览
软件工程实践2022年春W班
/
穿梭在银河的火箭队
/
FZUStudyRoom
通知
12
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
FZUStudyRoom
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b15524bf
编写于
5月 10, 2022
作者:
ItbGcthate
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
304_fix feature websockcet
上级
2061e024
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
55 addition
and
52 deletion
+55
-52
component/OnlineStudy/2-PlayerPKHome/index.js
component/OnlineStudy/2-PlayerPKHome/index.js
+1
-0
component/OnlineStudy/MyTest/index.js
component/OnlineStudy/MyTest/index.js
+2
-2
component/OnlineStudy/MyUtilities/index.js
component/OnlineStudy/MyUtilities/index.js
+52
-50
未找到文件。
component/OnlineStudy/2-PlayerPKHome/index.js
浏览文件 @
b15524bf
...
...
@@ -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
();
};
...
...
component/OnlineStudy/MyTest/index.js
浏览文件 @
b15524bf
...
...
@@ -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
();
}
...
...
component/OnlineStudy/MyUtilities/index.js
浏览文件 @
b15524bf
...
...
@@ -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
;
});
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录