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
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.
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.
@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?
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
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
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"})]
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:
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
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.
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
Comments
Unfortunately can't anything tell about close events. They should have worked, or were working before
unite can do that?
or this hack is the simplest way?:
http://appcodingeasy.com/Gideros-Mobile/Using-LuaSocket-in-Gideros
Fragmenter - animated loop machine and IKONOMIKON - the memory game
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
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
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.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
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?
Fragmenter - animated loop machine and IKONOMIKON - the memory game
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?
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
Fragmenter - animated loop machine and IKONOMIKON - the memory game
do you have any guess how can i notice and handle on client if the server stops? (and vice versa)
Fragmenter - animated loop machine and IKONOMIKON - the memory game
so again, "only" the problemremains with the two servers on one pc crash.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
thanks a lot
Fragmenter - animated loop machine and IKONOMIKON - the memory game
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"})]
Fragmenter - animated loop machine and IKONOMIKON - the memory game
You should use pcall when launching a server and catch the error if there is any and provide a message to user.
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:
(thanks)
Fragmenter - animated loop machine and IKONOMIKON - the memory game
pcall should have catched the error like try catch block.
Is error different with pcall?
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
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Fragmenter - animated loop machine and IKONOMIKON - the memory game
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.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
on the player with the "ads" plugin the following error:
Is there an idea why this is happening ??
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
Likes: SinisterSoft
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!