It looks like you're new here. If you want to get involved, click one of these buttons!
function onAccept(e) --auto accept client with provided id serverlink:accept(e.data.id) end --create a server instance serverlink = Server.new({username = 'myServer'}) --add event to monitor when new client wants to join serverlink:addEventListener('newClient', onAccept) --start broadcasting to discover devices serverlink:startBroadcast() --and then before entering game logic --if we are ready toplay --stop broadcasting serverlink:stopBroadcast() --and start only listening to clients serverlink:startListening() |
function onJoin(e) --auto connect to server with provided id serverlink:connect(e.data.id) end --create client instance serverlink = Client.new({username = 'IAmAClient'}) --create event to monitor when new server starts broadcasting serverlink:addEventListener('newServer', onJoin) --event to listen if server accepted our connection serverlink:addEventListener('onAccepted', function() print('server accepted our connection') end) |
--we can get all devices that are connected to our network local devices = {} serverlink:addEventListener('device', function(e) print(e.data.id, e.data.ip, e.data.host) devices[e.data.id] = {} devices[e.data.id].ip = e.data.ip devices[e.data.id].name = e.data.host end) serverlink:getDevices() --add some methods, that could be called by other clients or server through network --draw something serverlink:addMethod('draw', self.drawLine, self) --end drawing serverlink:addMethod('end', self.stopDrawing, self) --clear drawing serverlink:addMethod('clear', self.reset, self) --then you can call this methods when needed serverlink:callMethod('clear') serverlink:callMethod('draw', someX, someY) --or call method of specific device using it's id serverlink:callMethodOf('clear', 112233) serverlink:callMethodOf('draw', someX, someY, 112233) --and when game is finished serverlink:close() --and that's all |
Likes: fxone, AlexRu, Mells, altai, HubertRonald, Yan, Holonist, Tom2012, avo, hgvyas123, GregBUG, bowerandy, gorkem, Teranth, QuasarCreator, Nascode, jack0088, phongtt, oleg
Dislikes: giangkieugk
Comments
Many thanks and best regards,
ps: is that the voice of your kid in the video ?
http://www.nightspade.com
yep it is my kid, that was a hard day for him, because daddy was playing with ipods and mobiles all day. The problem is that he wanted to play with them He's got very good at using ipod.
And ipod is just small enough not to skate on it
Website: http://www.castlegateinteractive.com
https://play.google.com/store/apps/developer?id=Castlegate+Interactive
i'm waiting for glass digitizer (it come from olanda) then my ipad back to life...
www.tntengine.com
Amazing, I'm looking forward to integrating this in my app.
Question that might be out of the scope of this thread : Is that possible, in one way or another, that a client joins the server without having the app installed on both devices? (server only)?
See Mario Kart's Download Play
It is possible, but I'd probably wouldn't do it. As it will be hard to install an app that loads some code dynamically by Apple terms
I see, thank you for the answer.
But right now, yeah it's still possible to do this, but you must implement same protocol that Gideros Unite uses. I may need to write some docs to explain different commands it handles. But it is possible.
If you are interested in it, let me know and I'll prepare the docs.
I also had an idea of creating a php script using sockets and same protocol for creating central remote server. But probably won't have enough time to complete it in near future
I was wondering (before I can try myself it this weekend) do you think there is a delay from client to server?
For example for a game like ready steady bang where each millisecond counts, should I consider that this kind of system would never be fast enough? (obviously I am talking about the system itself, not about your coding abilities
So some different approach is needed.
Let's say (using minutes:seconds:millisecond format) :
Server sends a start countdown signal at 00:00:000, and bang signal should appear after 3 seconds.
So server starts countdown immediately and bang signal appears in 00:03:00.
But other phone receives signal at 00:00:100 and only then launches the countdown, which will end at 00:03:100. As you see other phone has disadvantage.
What we do, as we take current time in each device separately, when countdown starts
So even if other phone receives bang signal 100ms later, it's relative time would still be the same, from countdown start, to shooting time.
Hope that clears something
that would work
That will be a bit harder to add to my game because I check victories differently (with handicap and delay for some characters etc) and I remove the event listener for the second player as soon as the first one has played (lot of behaviors depend on that choice that I made from the beginning) so I can't compare their relative times without having to rewrite other areas.
The app grew up beyond my plan, a few parts are in spaghetthi mode (I know it's bad... will do better next time!).
But this framework would be perfect for my game, I'll experiment after the initial release.
This works great. I am trying to get my head around the code now.
There is one thing I notice though so can you give me an explanation?
1. I loaded the DrawTogether sample into Gideros
2. I changed my Player settings to run on the player on my iphone and ran the code from the editor. The start screen comes up with Start new, Join and About buttons on the iPhone.
3. Switched over to the editor and changed the player settings to localhost and ran the code again. The start screen comes up with Start new, Join and About buttons on the PC player as well. So far so good.
4. I can now start a server on the iPhone and Join from the PC but not vice versa. If I start the server (Start new) on the PC Player the iPhone does not show that a server is available and I cannot join.
But if I start the server on the iPhone and join from the PC Player instance then everything works fine.
Is there a reason for this? Is it something in the code or is it the setup I am using?
it's really hard to tell, where is the problem.
I vaguely remember some problem with discovering, let's see if this makes difference.
For example, in Gideros Studio you start app in IOS player, then change to localhost (so localhost now has active connection to Gideros Studio) and then you try your experiment.
What about if you do it vice versa, first you connect to localhost and start the app, then switch to IOS player and start the app there, so IOS app remain the active connection to Gideros Studio. Does it change anything?
Likes: ar2rsawseen
The only 2 things I have not tried are (1) to create an .ipa and install on 2 devices and then test and that is not possible now for me and (2) Disable the Firewall on my PC and try again.
So to be very clear, irrespective of whichever session is the current connection to Gideros, the server broadcast from the Gideros PC Player is NOT seen by the session running on my iPhone player, but the server running on the iPhone player is seen by the Gideros player and works fine.
I also tried this:
I ran the player on my iPad1 and ran the app on Gideros, ran the player on iPhone and ran the app on Gideros and finally ran the PC player and ran the app.
Between the iPad and the PC there is no problem connecting either way (server or client)
But on the iPhone it only works as a server which both the PC and the iPad can connect. The iPhone session does not "see" the server sessions of either the iPad or the PC player.
I was able to run 3 separate sessions on each device and by setting the iPhone as the server, could connect from the PC and iPad and have a 3 way session that worked.
This leads me to the conclusion that there is some problem with the iPhone player and not actually with your code.
Only thing that comes to mind, is that you might have two Internet connections on your Iphone (local wifi network, and some 3g from your carrier) and maybe it automatically selects 3g connection from your carrier and not a local wifi?
@paul_k_clark ooh, thank you!
Also as I said above the app works fine as long as the iPhone is the server. It just does not work when acting as a client.