Xojo Network Card Games

  1. ‹ Older
  2. 4 months ago

    If I use AutoDiscovery, do I set it as a property, class, class interface, etc? I tried setting it as a Class with Super as AutoDiscovery but I get syntax errors saying "This item doesn't exist" when I try setting a port number using the following code:

    ADController.Bind(9097)
  3. Jeff T

    Sep 5 Midlands of England, Europe
    Edited 4 months ago

    In the Xojo examples, Internet/Communication, there is an 'Autodiscovery' example
    Which I guess you must have found, since the name of the control it uses is ADController

    Since it shows the class as being on a window, with event handlers, the best way to deal with this is to have a single window that holds the control, with implicit instantiation turned on, so that there is one and one only instance of the window.

    So take the example, strip it back to bare bones (or not.. make it invisible if you like until you are comfortable with what it does), and use the one and only instance of the window as your network controller.

    If it is called wndController, show it once at startup. (doesnt even have to be visible)

    wndController.show

    not

    w = new wndController
    w.show

    After that, events will fire on that window.
    It can store data into global variables, and properties of the wndController window can be accessed from any other window by referring to it by name

    eg

    wndController.player1name
  4. I must be doing something wrong as the instances of the app do not seem to see each other. I set up a separate windows called:

    frmNetworkConnection

    I added a UDPSocket with a Super of AutoDiscovery and added a Method of RecievedMessage to it and added code to let me know that a message is being received from the app on the other computer.

    I also added code to the App.Open Event:

    frmNetworkConnection.ADController.Bind( 9097 )
    If frmNetworkConnection.ADController.LastErrorCode <> 0 Then
      MsgBox("Error binding port.")
      Quit
    End If
    frmNetworkConnection.ADController.Register("yugiohds")
    frmNetworkConnection.ADController.UpdateMemberList

    Which is similar to the code from the AutoDiscovery example.

    I have a button which sends the message so I can check to make sure they see each other:

    frmNetworkConnection.ADController.SendMessageToGroup(0 , "Testing, 123." )

    But only the sending app can receive the message. I'm sure it's something so simple I am not doing correctly.

    In the frmNetworkConnection I have a lists identical to the one in AutoDiscovery example so I can see for sure that messages are being sent and received.

    The AutoDiscovery example works no problem with my setup which is a MacBook Pro and a Virtual Machine with Windows 10 in bridged mode so the Virtual Machine is on the same Network as the host machine.

  5. I am at a complete loss as to why this isn't working in my game. I literally copy and pasted the COMPLETE AutoDiscovery Window and its contents into my game and set it as the opening Window. The 2 apps for whatever reason won't see each other. Yet if I use the example file, it works great.

    I even tried 2 separate computers, my MacBook Pro and a regular Windows 10 PC. No dice.

  6. Edited 4 months ago

    I finally figured out this issue which I don't think makes any sense. The Mac version was being debugged as a 64-bit app while the Windows version was being debugged as a 32-bit since the Windows IDE won't run a 64-bit app.

    Once I set the Mac version to 32-bit it all worked. Really frustrating.

    The one thing I can't figure out is why a message sent to the Mac OS version gets doubled.

  7. Is there an easier way of sending variables to and from the apps? Something where I can send an entire class object. I could use a JSON string but certain variables would be simpler to send if I could send the whole class of variables.

  8. Wayne G

    Sep 8 Pre-Release Testers, Xojo Pro New Zealand axisdirect.nz

    Store your data in a new framework dictionary. You can easily convert this to & from json (http://developer.xojo.com/xojo-data$ParseJSON ). Use computed properties to reference the data in the dictionary so you're not always looking up key value pairs (and don't have to rewrite your code).

  9. Quick question: How do I tell when 2 players are connected in the same group so the game can move on to the next screen?

  10. scott b

    Sep 11 Pre-Release Testers, Xojo Pro local coffee shop

    @Charles F Quick question: How do I tell when 2 players are connected in the same group so the game can move on to the next screen?

    have a unique UUID created for each new game and that unique ID can be shared when players connect. that way you know when two+ players are grouped together.

  11. Edited 4 months ago

    I already use a Group ID but I can't seem to figure out how to tell when an instance of the game actually connect to the group. Also I've noticed that for some reason when a Mac version receives a message it's doubled. Even the AutoDiscovery example does this but only when a Mac version receives a message.

    Edit: I take it partially back both Windows and Mac double the messages while using the AutoDiscovery example code.

  12. I'm still having issues figuring out how to actually connect to another instance of the app. They can see each other but I'm at a loss on how to actually complete the connection so no one else can try to connect. Should I do a Host/Guest setup or something else. I need some direction as this is all new to me.

    I directly imported the AutoDiscovery Window into my game and use that to start the connection but I still can't figure out how to tell if another instance of the app has connected to the group.

  13. How do I get the IP Address of the other player? Do I have to send it manually or is there an easier way to do it?

  14. shao s

    Sep 23 Pre-Release Testers Sudbury, Ontario, Canada

    It should just be the address property of the TCPSocket for that player..

  15. So I have to manually send a player's IP Address to the other player?

  16. Tim H

    Sep 23 Pre-Release Testers Portland, OR USA

    It should be in the RemoteAddress property already.

  17. There doesn't seem to be a RemoteAddress property. I am using AutoDiscovery. Is that the reason? If so can someone help me set this up without using AutoDiscovery then?

  18. Dave S

    Sep 23 San Diego, California USA

    AutoDiscovery.GetMemberList
    Method

    AutoDiscovery.GetMemberList ( ) As String()

    Returns a String array of IP addresses belonging to the list of machines on the network who are in the group.

  19. I am clearly doing something wrong as when I assign AutoDiscovery.GetMemberList to a variable, it's empty.

  20. Would it be easier if I did a Host/Guess setup? If so how do I do that?

  21. Tim H

    Sep 23 Pre-Release Testers Portland, OR USA

    If you're using AutoDiscovery, then every message is accompanied by the IP address it was from. Use that to respond to a particular player.

or Sign Up to reply!