I cannot seem to get this code to work. Anyone have any success with the networking commands with AppGameKit?
rem
rem AGK Application
rem
rem Landscape App
global myPort as integer
global myNetwork as integer
global myListener as integer
global myNetworkConnected as integer
global myMessage as integer
global clientNetworkName as string
global clientNetworkID as integer
global asServer as integer
if getmultitouchexists() = 0
asServer = 1
endif
if asServer = 1
myPort = random(1025, 45630)
myNetwork = HostNetwork("Porkchop Sandwiches", "host", myPort)
endif
myNetworkConnected = 0
do
if myNetworkConnected = 0 and asServer = 0
myListener = CreateBroadcastListener(45631)
tNetworkID as integer
tNetworkID = GetBroadcastMessage(myListener)
while tNetworkID > 0
if myNetworkConnected = 0
message("foo")
clientNetworkName = getNetworkMessageString(tNetworkID)
clientNetworkID = JoinNetwork(clientNetworkName, "client" + str(random(1,128)))
myNetworkConnected = 1
endif
deletenetworkmessage(tNetworkID)
tNetworkID = GetBroadcastMessage(myListener)
endwhile
Deletebroadcastlistener(myListener)
elseif myNetworkConnected = 1 and asServer = 0
if isNetworkActive(clientNetworkID) > 0
myNetworkConnected = 2
endif
elseif myNetworkConnected = 0 and asServer = 1
myMessage = CreateNetworkMessage()
AddNetworkMessageString(myMessage, "Porkchop Sandwiches")
SendNetworkMessage(myNetwork, 0, myMessage)
if isNetworkActive(myNetwork) > 0
myNetworkConnected = 1
endif
endif
rem print data to screen
if asServer = 0
print(clientNetworkName)
if isNetworkActive(clientNetworkID) > 0
print("connected")
else
print("disconnected")
endif
`endif
else
print("Porkchop Sandwiches")
if myNetwork > 0
if isNetworkActive(myNetwork) > 0
print("connected")
else
print("disconnected")
endif
endif
endif
Sync()
loop
EDIT: So, testing out the basic included networking demo in AppGameKit, I discovered that in order for multiplayer to work, my iPhone always has to host the game while my PC has to connect.
Otherwise... it doesn't work
Hi there. My name is Dug. I have just met you, and I love you.