[test] request char
This commit is contained in:
@@ -27,8 +27,8 @@ export async function createMultiuserRoom(){
|
|||||||
|
|
||||||
peer.on('connection', function(conn) {
|
peer.on('connection', function(conn) {
|
||||||
connections.push(conn)
|
connections.push(conn)
|
||||||
conn.on('data', function(data:ReciveData) {
|
console.log("new connection")
|
||||||
if(data.type === 'request-char'){
|
function requestChar(){
|
||||||
const db = get(DataBase)
|
const db = get(DataBase)
|
||||||
const selectedCharId = get(selectedCharID)
|
const selectedCharId = get(selectedCharID)
|
||||||
const char = cloneDeep(db.characters[selectedCharId])
|
const char = cloneDeep(db.characters[selectedCharId])
|
||||||
@@ -41,6 +41,12 @@ export async function createMultiuserRoom(){
|
|||||||
data: char
|
data: char
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
requestChar()
|
||||||
|
|
||||||
|
conn.on('data', function(data:ReciveData) {
|
||||||
|
if(data.type === 'request-char'){
|
||||||
|
requestChar()
|
||||||
|
}
|
||||||
if(data.type === 'receive-char'){
|
if(data.type === 'receive-char'){
|
||||||
const db = get(DataBase)
|
const db = get(DataBase)
|
||||||
const selectedCharId = get(selectedCharID)
|
const selectedCharId = get(selectedCharID)
|
||||||
@@ -86,10 +92,6 @@ export async function joinMultiuserRoom(){
|
|||||||
|
|
||||||
let open = false
|
let open = false
|
||||||
conn.on('open', function() {
|
conn.on('open', function() {
|
||||||
open = true
|
|
||||||
conn.send({
|
|
||||||
type: 'request-char',
|
|
||||||
});
|
|
||||||
conn.on('data', function(data:ReciveData) {
|
conn.on('data', function(data:ReciveData) {
|
||||||
switch(data.type){
|
switch(data.type){
|
||||||
case 'receive-char':{
|
case 'receive-char':{
|
||||||
|
|||||||
Reference in New Issue
Block a user