Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

P2P not working in vue app #495

Open
gowram opened this issue Jun 23, 2023 · 10 comments
Open

P2P not working in vue app #495

gowram opened this issue Jun 23, 2023 · 10 comments
Assignees
Labels
api An issue, task, or discussion related to public runtime APIs help wanted Extra attention is needed

Comments

@gowram
Copy link

gowram commented Jun 23, 2023

Vue js app with P2P not working..

i have build application with v0.3.3 with vue.js it is loading fine in both Desktop (ubuntu) and mobile but communication not happening between two devices.

I have uploaded my code for your review,
https://github.com/gowram/sscvue

@heapwolf please, let me know what is missing here....

@jwerle jwerle added help wanted Extra attention is needed api An issue, task, or discussion related to public runtime APIs labels Jun 23, 2023
@heapwolf
Copy link
Member

@gowram please point to a repo or a gist. No one will open a zip file.

@gowram
Copy link
Author

gowram commented Jun 24, 2023

@gowram
Copy link
Author

gowram commented Jun 27, 2023

team,
any update on this?
I would like to know what is missing from my setup...

<script setup>
import { Peer } from 'socket:peer'
import { ref, onMounted } from 'vue'



onMounted(async () => {
  const pair = await Peer.createKeys()
  const clusterId = await Peer.createClusterId()
  peer = new Peer({ ...pair, clusterId })
  peer.join()
  peer.on('greeting', (data, ppr, address, port) => {
    clr.value = "color = " + data.color;
    if (peer.peer.address !== ppr) {
      console.log('remote on...')     
    }
    setColor(data.color)
  })
})

defineProps({
  msg: String,
})

const count = ref(0)

let peer = ref("")
let ip = ref("loading....")
let clr = ref("black")

const setColor = c => document.body.style.backgroundColor = `#${c}`

function setBgColor() {
  const color = Math.floor(Math.random() * 16777215).toString(16)
 
  peer.emit('greeting', {
    'color': color,
    'timestamp': Date.now()
  })
  setColor(color);
  ip.value = peer?.peer?.address
} 
</script>

<template>
  <h1>{{ msg }}</h1>
  <h2>{{ ip }}</h2>
  <h3>{{ clr }}</h3>
  <div class="card">
    <button type="button" @click="setBgColor">Change Color</button>
  </div>
</template>

<style scoped>
.read-the-docs {
  color: #888;
}
</style>`

@RGBboy
Copy link

RGBboy commented Jun 27, 2023

Try using the same clusterId and key pair between devices that you want to connect.

@gowram
Copy link
Author

gowram commented Jun 28, 2023

@RGBboy I tried with same clusterId and keypair between devices, Still it's not working..

peer.on itself not getting listened, if i use same clusterId and keypair.

is there any documentation available?

@sheldonth
Copy link

Just to add to this, also trying to set up a demo. Not using vue but in vanilla js I'm not seeing theawait peer.join() function ever return. I'm using a shared clusterId. I'm not sure why I would use the same keypair on the two clients. Testing between a Mac and iPhone on the same network.

Source code is at https://github.com/sheldonth/perchd/blob/main/src/index.js if anyone can help. Much appreciated.

@heapwolf
Copy link
Member

today's merge will add the fix to main branch

@gowram
Copy link
Author

gowram commented Oct 10, 2023

@heapwolf is there any update on this issue?

@chicoxyzzy
Copy link
Member

Was this fixed?

@lamiazar
Copy link
Member

Was this fixed?

not yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api An issue, task, or discussion related to public runtime APIs help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

7 participants