Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 2 Support (Qt 5) › Error in OneCard example

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #23356

    Peter

    Hi, I installed Felgo on 2 clients at home to learn about your Multiplayer communication and when I try to use your OneCard example, I experience following error in leader application output:

    ReferenceError: message is not defined

    when hitting the if line:

          else if (code == messageTriggerTurn){
            multiplayer.leaderCode(function() {
              // the leader only stops the turn early if the requesting user is still the active player
              if (multiplayer.activePlayer && multiplayer.activePlayer.userId == message){
                triggerNewTurn()
              }

    Sender is not the leader and code looks like:

    var userId = multiplayer.activePlayer ? multiplayer.activePlayer.userId : 0
    multiplayer.sendMessage(messageTriggerTurn, userId)

    console.debug(userId) before sendMessage prints a number, so its not undefined while sending

     

    using ubuntu on both clients,debugbuild and I havent changed the sourcecode.

    #23362

    Peter

    Somehow  message goes out of scope before it will be used in the else if clause. So I changed the CardONU code accordingly

        onMessageReceived: {
    
          var tempMessage=message
      else if (code == messageTriggerTurn){
            multiplayer.leaderCode(function() {
              // the leader only stops the turn early if the requesting user is still the active player
              if (multiplayer.activePlayer && multiplayer.activePlayer.userId == tempMessage){
                triggerNewTurn()
              }

    Maybe someone can explain me why message goes otherwise out of scope.

    #23373

    Alex
    Felgo Team

    Hi Peter,

    I guess this could be caused because it is used in the callback of the leaderCode function, thus could be delayed in execution. I would have to dig into the code myself to validate this though.

    Best,
    Alex

    #23404

    Peter

    Hi Alex, thank you for your response. I am struggeling right now with your messaging system from your oneCard example. Sometimes the sequential ordering messes up. I dont know if this is the expected behaviour.

    multiplayer.sendMessage(gameLogic.messageSetGlobalSate, {globalState: true, userId: senderId})
    
    multiplayer.sendMessage(gameLogic.triggerNewTurn, {userId: senderId})

    Sometimes the triggerNewTurn  message reaches the other clients before the State , even if I release the triggerNewTurn after a 4 seconds Timer.

    So my question is. How can I check if a message was received by all other players before triggering a new turn?

     

    #23411

    Peter

    I got the fundamental concept wrong. I thought turnStarted(playerId) gets invoked online on playerIds client. So probably that messed everything up

Viewing 5 posts - 1 through 5 (of 5 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded