MergGK Game Center Peer to Peer

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Aduro91
Posts: 58
Joined: Sat Jul 22, 2023 8:49 pm

MergGK Game Center Peer to Peer

Post by Aduro91 » Tue Aug 29, 2023 12:53 am

Hey all,

I'm working on trying to incorporate online multiplayer into my game via MergGk http://mergext.com/home/merggk/. I've managed to integrate the app with Game Center. I have the app logged into a Game Center account on the test iPhone simulator and a different account on an actual iPhone. I definitely manage to get authentication. I use:

on mergGKLocalPlayerAuthenticated pPlayerID,pPlayerAlias,pPlayerDisplayName
put pPlayerID into field "playerID"
end mergGKLocalPlayerAuthenticated

Comes up with the respective IDs on each test source.

What I cant do is any of the peer-to-peer stuff.

The documentation says that the command mergGKStartPeer 'Register(s) as a peer in the GameKit peer-to-peer session'. But what session is this, does it start a session?

I have both test sources using this command and then I've tried sending some data.

On one of the sources:

put field "data" into pData
mergGKSendToAllPeers pData

Then I make sure one can recieve the data. In the documentation it says the message mergGKDataReceived is sent to the control that called mergGKStartPeer when a peer sends some data. (pPeerID,pData)

So I tried putting this in the card since that's where I put mergGKStartPeer:

on mergGKDataReceived pData
put pData into field "incomingdata"
end mergGKDataReceived

Nothing.

I tried puttting the pPeerID in a field on each test source and both are '1'...?

Obviously missing something, can anyone point me in the right direction?

Aduro91
Posts: 58
Joined: Sat Jul 22, 2023 8:49 pm

Re: MergGK Game Center Peer to Peer

Post by Aduro91 » Tue Aug 29, 2023 1:51 am

Aduro91 wrote:
Tue Aug 29, 2023 12:53 am
...

Then I make sure one can recieve the data. In the documentation it says the message mergGKDataReceived is sent to the control that called mergGKStartPeer when a peer sends some data. (pPeerID,pData)

So I tried putting this in the card since that's where I put mergGKStartPeer:

...
So I just realised this could be a problem. A card isn't a control? I still dont think changing this will fix the whole thing. Feels like there should be a function to create a match/GameKit session, and then one to join, THEN peers will have a unique id and the data could be sent.

But I'll try changing to an actual control...

Post Reply