View Full Version : Help needed for moonbox a new messenger in ams
infinityscape
01-09-2010, 02:55 AM
hi, i am currently working on a messenger in ams. i have run into a problem and was wondering if anyone could fix this, i am using a timer for every second the app checks a table and if any changes are detected it updates the chat but using a timer just makes the application lockup :eek:. is there a way to do this with out the application locking up but still checking every second or so?
Moonbox In Action:
http://img.lunastudios.co.uk/screenshots/moonboxscreenshot1.png
Thanks,
Nathaniel Blackburn
Sakuya
01-09-2010, 03:33 AM
Use coroutines?
infinityscape
01-09-2010, 03:42 AM
please could you show me a example of what you mean, i am aware of this just not how to excecute it, the function that need to be repeated are:
MySQL.QueryToTable("SELECT * FROM `mainchat`");
if lastcheck ~= nil and MySQL.GetRows() ~= lastcheck then
moonbox.GetOnlineUsers();
moonbox.MainChat();
lastcheck = MySQL.GetRows();
end
Sakuya
01-09-2010, 03:49 AM
I don't really know how to use them myself, I just thought if you were running these functions in another thread it wouldn't lock up.
Also, MySQL.. for chat?
infinityscape
01-09-2010, 03:52 AM
yes, im using mysql, im being rather experimental but it works fine, i just need to find a way of doing this without it locking up :lol ill look into using coroutines (coroutine.create) i dont know anything about using myself haha
infinityscape
01-09-2010, 09:25 AM
i have no idea how to get this to work, if someone can please help me i will appeciate it alot its really fustrating because i have been working on it none stop and this is the only thing stopping me from finishing the application, without this working i cant continue, please help :huh
Ulrich
01-10-2010, 01:05 PM
Hi,
without seeing the source code, we can only suspect what is happening when the application locks up, but I suspect that you are encountering race conditions, and you may be ignoring error codes returned from the MySQL server, trying to parse results when there were none. If you need concurrent write access to tables, you can, for example, use an auxiliary table where you store the id of the client with current write privileges. If the table is currently locked, retry after a few seconds until you obtain the lock, do your thing and then clear the lock. (A timestamp might be useful as well, avoiding infinite locks when the client died before unlocking the table.) You can use, as well, a specific SQL syntax for table and row-locks (see here (http://dev.mysql.com/doc/refman/4.1/en/innodb-transaction-model.html)).
But, if you would ask me, I would tell you to build the chat server with sockets instead: only the chat server would be "talking" to the MySQL server, while the chat server communicates with its clients over a group of TCP/IP sockets.
Ulrich
ShadowUK
01-10-2010, 01:55 PM
But, if you would ask me, I would tell you to build the chat server with sockets instead: only the chat server would be "talking" to the MySQL server, while the chat server communicates with its clients over a group of TCP/IP sockets.
Ulrich
Yeah, that's pretty much how it's done.
infinityscape
01-11-2010, 02:38 AM
ok you have a point ulrich, i have purchased your socket plugin because mysql really isnt working for this, thanks for your help and understanding :)
Powered by vBulletin™ Version 4.0.6 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.