Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Gideros Unite: framework for multiplayer mobile games - Page 3 — Gideros Forum

Gideros Unite: framework for multiplayer mobile games

13»

Comments

  • if it is possible not to use 127.0.0.1 but computer's ip address to do local connections too, then you would need only one server. Need to try it.

    Unfortunately can't anything tell about close events. They should have worked, or were working before :)
  • thanks, i will try with the ip of the pc instead of 127.0.0.1 if it works, but for that i would need the local ip, is there a way to get it in gideros?
    unite can do that?
    or this hack is the simplest way?:
    http://appcodingeasy.com/Gideros-Mobile/Using-LuaSocket-in-Gideros
  • yes, this hack is also what used inside Unite.
    If you don't set server IP it should detect it this way, so you can try.

    I just don't remember if it would not get the complete outside ip of your router and not pc, but probably it won't
  • keszeghkeszegh Member
    edited September 2015
    good progress!
    so i've set it up so that a client-app first makes a unite client directly trying to connect to a server on the same machine (having same ip) and after a timeout of 1 sec it stops this and tries to connect on the network. that's reasonably fine, 1 sec delay is tolerable.

    now the only remaining problem is that if on one pc in 2 instances of the app i both start a server then (on the app where i start the server later) Unite crashes at line
    assert(self.listen:sendto(msg, self.conf.multicast, self.port3))
    in function
    function Server:broadcastStep()
    As it's impossible to stop a user from accidentally pressing the 'make server' button on both instances, i need a solution so that the app does not crash. any ideas? thanks

    btw events when server/client disconnects still not work, so e.g. when client disconnects then the user needs to manually stop the server, but that's again something i can live with.

    also as a remark in Unite in the function
    function Client:sendMsg(msg, type)
    	if type == nil then
    		if self.conf.connectionType == "both" then
    			type = "tcp"
    		else
    			type = self.conf.connectionType
    		end
    	end
    	if type == "tcp" then
    		local byte, err = self.tcp:send(msg)
    		if err == "closed" then				
                    self:dispatchEvent(self.connectionClosedEvent)		
    		end
    	else
    		assert(self.udp:sendto(msg, self.serverIP, self.port2))
    	end
    end
    i had to change
    self:dispatchEvent(self.connectionClosedEvent)
    to
    self:dispatchEvent(Event.new("onServerClose"))
    otherwise it crashed at some point. i really could not understand how it happened, but somehow self.connectionClosedEvent was a string containing the client name instead of the event.
  • ok, thanks, want to submit a pull request? :)
  • @ar2rsawseen - ?
    i did changes only in my code, i did not change unite at all, except
    i had to change
    self:dispatchEvent(self.connectionClosedEvent)
    to
    self:dispatchEvent(Event.new("onServerClose")).
    but that looks more like a hack, so it's not a worthy change to pull it.
    or was your comment supposed to be in another topic?
  • no, ok, no problem, I just thought maybe there was something more.

    hmm, and I still don't get why previous code did not work.
    Other events seem to work though, right? Or you need to do same on client close too?
  • keszeghkeszegh Member
    edited September 2015
    so a little update, if after disconnecting i do some callmethods on the other machine then at some point it gets the event that there is a disconnection. only without doing nothing this does not happen. so i guess that's a normal behaviour IF we consider this event as an "error report".
    yet it does not work also as a report when a deliberate disconnection is happening (by the documentation one would expect it though) so probably it's easiest to add a method for noticing when the other machine closes connection and when i deliberately close a connection then i call this method on the other machine so that he knows that we left the lobby, so to speak.

    so after all only one real problem remains:
    if on one pc in 2 instances of the app i both start a server then (on the app where i start the server later) Unite crashes at line
    assert(self.listen:sendto(msg, self.conf.multicast, self.port3))
    in function
    function Server:broadcastStep()
    As it's impossible to stop a user from accidentally pressing the 'make server' button on both instances, i need a solution so that the app does not crash. any ideas? thanks

  • keszeghkeszegh Member
    edited September 2015
    well, after a lot of trials, i failed with my above plan of adding a method which calls a function to stop the client. it crashes, i guess somehow when a method is called at the end unite does something else, but as meanwhile i've stopped the client it does not know what to do or something. i just guess.
    do you have any guess how can i notice and handle on client if the server stops? (and vice versa)
  • wow, i became desperate and i put my destructor function (which calls serverlink:close()) into a Timer.delayedCall(1,destFunction) and it works, i just hope this workaround is stable enough.

    so again, "only" the problemremains with the two servers on one pc crash.
  • @ar2rsawseen, sorry for bothering still. overall it works for me for what i need, crashes here and there if i abuse connecting/disconnecting but overall bearable. the only obvious dealbreaker problem is with making 2 servers on one computer, then it crashes all the time. any workarounds for that maybe?
    thanks a lot
  • It means that the solution of using PC's IP address did not work?
  • keszeghkeszegh Member
    edited September 2015
    about that you were right, it works. (so setting up a normal server and then on the same pc another app as client directly trying to connect to its own ip will make a connection, all good)
    the problem is if the user for some reason starts a server on both apps on same pc (and not one server and one client), then it crashes.
    [i use serverlink = Server.new({username = 'myServer',connectionType="tcp"})]
  • aha, I see. problem is that only one single server be on the same ip address with the same port.

    You should use pcall when launching a server and catch the error if there is any and provide a message to user.
  • keszeghkeszegh Member
    edited September 2015
    i never used pcall, so it's time to learn it i guess.
    when starting the second server it crashes with error in
    function Server:broadcastStep()
    in line:
    assert(self.listen:sendto(msg, self.conf.multicast, self.port3))

    so what should i do so that there is no crash? how to catch error?
    i tried in my code to do it this way:
    if pcall(
    function() 
    serverlink = Server.new({username = 'myServer',connectionType="tcp"}) 
    end
    ) then
    ....
    else
    print("error")
    end
    but it still crashes. should i do something straight in unite.lua? what?
    (thanks)
  • really?
    pcall should have catched the error like try catch block.

    Is error different with pcall?
  • How about if you do
    local status, serverlink = pcall(Server.new, {username = 'myServer',connectionType="tcp"})
    ?
  • that works i think,
    i tried the same actually just now but i also messed up things a bit and added another pcall inside unite, but the error is catched but it's not working at all. i hope i can fix it back, i will let you know if there is still problems. thanks
  • keszeghkeszegh Member
    edited September 2015
    EDIT: nevermind, i realized i made a mistake when copying your line.
  • it's still not good.
    i think the problem is that in unite the function that throws error is put on eventTimer and so it throws errors all the time, so i need to catch the error inside unite.lua. i will try to modify it this way, i hope i will succeed.
  • olegoleg Member
    edited February 2018
    There are no errors on the standard player - "C:\Program Files (x86)\Gideros\Players\GiderosAndroidPlayer.apk" *2018.2.1


    on the player with the "ads" plugin the following error:
    Uploading finished.
    Uploading finished.
    classes/socket.lua:12: module 'socket.core' not found:
    	no field package.preload['socket.core']
    	no file './socket/core.lua'
    	no file './socket/core/init.lua'
    	no file './_LuaPlugins_/socket/core.lua'
    	no file './_LuaPlugins_/socket/core/init.lua'
    	no file '/usr/local/share/lua/5.1/socket/core.lua'
    	no file '/usr/local/share/lua/5.1/socket/core/init.lua'
    	no file '/usr/local/lib/lua/5.1/socket/core.lua'
    	no file '/usr/local/lib/lua/5.1/socket/core/init.lua'
    	no file './socket/core.so'
    	no file '/usr/local/lib/lua/5.1/socket/core.so'
    	no file '/usr/local/lib/lua/5.1/loadall.so'
    	no file './socket.so'
    	no file '/usr/local/lib/lua/5.1/socket.so'
    	no file '/usr/local/lib/lua/5.1/loadall.so'
    stack traceback:
    	classes/socket.lua:12: in main chunk

    Is there an idea why this is happening ??
    my games:
    https://play.google.com/store/apps/developer?id=razorback456
    мій блог по гідерос https://simartinfo.blogspot.com
    Слава Україні!
  • you need to add the lua Socket plugin

    Likes: SinisterSoft

    my games:
    https://play.google.com/store/apps/developer?id=razorback456
    мій блог по гідерос https://simartinfo.blogspot.com
    Слава Україні!
    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.