Commit 77e14b21 authored by Chunchi Che's avatar Chunchi Che

handle join room

parent c7d63765
...@@ -189,7 +189,7 @@ export const CustomRoomContent: React.FC = () => { ...@@ -189,7 +189,7 @@ export const CustomRoomContent: React.FC = () => {
value={friendPrivateID} value={friendPrivateID}
onChange={onChangePrivateID} onChange={onChangePrivateID}
placeholder="在这输入你朋友的私密房间密码" placeholder="在这输入你朋友的私密房间密码"
type="number" type="text"
/> />
</div> </div>
); );
......
...@@ -46,7 +46,6 @@ export const Component: React.FC = () => { ...@@ -46,7 +46,6 @@ export const Component: React.FC = () => {
const [deckName, setDeckName] = useState(decks.at(0)?.deckName ?? ""); const [deckName, setDeckName] = useState(decks.at(0)?.deckName ?? "");
const user = accountStore.user; const user = accountStore.user;
const { joined } = useSnapshot(roomStore); const { joined } = useSnapshot(roomStore);
const { options, friendPrivateID } = mcCustomRoomStore;
const [singleLoading, setSingleLoading] = useState(false); // 单人模式的loading状态 const [singleLoading, setSingleLoading] = useState(false); // 单人模式的loading状态
const [athleticMatchLoading, setAthleticMatchLoading] = useState(false); // 竞技匹配的loading状态 const [athleticMatchLoading, setAthleticMatchLoading] = useState(false); // 竞技匹配的loading状态
const [entertainMatchLoading, setEntertainMatchLoading] = useState(false); // 娱乐匹配的loading状态 const [entertainMatchLoading, setEntertainMatchLoading] = useState(false); // 娱乐匹配的loading状态
...@@ -109,7 +108,7 @@ export const Component: React.FC = () => { ...@@ -109,7 +108,7 @@ export const Component: React.FC = () => {
); );
if (mcServer) { if (mcServer) {
const passWd = getCreateRoomPasswd( const passWd = getCreateRoomPasswd(
options, mcCustomRoomStore.options,
String(getPrivateRoomID(user.external_id)), String(getPrivateRoomID(user.external_id)),
user.external_id, user.external_id,
true, true,
...@@ -123,7 +122,29 @@ export const Component: React.FC = () => { ...@@ -123,7 +122,29 @@ export const Component: React.FC = () => {
} }
}; };
// 加入MC自定义房间 // 加入MC自定义房间
const onJoinMCRoom = () => {}; const onJoinMCRoom = async () => {
if (user) {
if (mcCustomRoomStore.friendPrivateID !== undefined) {
const mcServer = serverList.find(
(server) => server.name === "mycard-custom",
);
if (mcServer) {
const passWd = getJoinRoomPasswd(
String(mcCustomRoomStore.friendPrivateID),
user.external_id,
true,
);
await connectSrvpro({
ip: mcServer.ip + ":" + mcServer.port,
player: user.username,
passWd,
});
}
} else {
message.error("请输入朋友的私密房间密码!");
}
}
};
// MC观战 // MC观战
const onMCWatch = () => { const onMCWatch = () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment