[test] request char

This commit is contained in:
kwaroran
2023-11-22 19:00:09 +09:00
parent 611f2c074d
commit 043ac92260

View File

@@ -27,19 +27,25 @@ export async function createMultiuserRoom(){
peer.on('connection', function(conn) {
connections.push(conn)
console.log("new connection")
function requestChar(){
const db = get(DataBase)
const selectedCharId = get(selectedCharID)
const char = cloneDeep(db.characters[selectedCharId])
if(char.type === 'group'){
return
}
char.chats = [char.chats[char.chatPage]]
conn.send({
type: 'receive-char',
data: char
});
}
requestChar()
conn.on('data', function(data:ReciveData) {
if(data.type === 'request-char'){
const db = get(DataBase)
const selectedCharId = get(selectedCharID)
const char = cloneDeep(db.characters[selectedCharId])
if(char.type === 'group'){
return
}
char.chats = [char.chats[char.chatPage]]
conn.send({
type: 'receive-char',
data: char
});
requestChar()
}
if(data.type === 'receive-char'){
const db = get(DataBase)
@@ -86,10 +92,6 @@ export async function joinMultiuserRoom(){
let open = false
conn.on('open', function() {
open = true
conn.send({
type: 'request-char',
});
conn.on('data', function(data:ReciveData) {
switch(data.type){
case 'receive-char':{