Monkuar Posted September 13, 2013 Share Posted September 13, 2013 (edited) I am making a turned based rpg text game. But I get $.post within jquery for the attacking a mob sequence. Each time a user attacks a mob (everything is validated serverside) and processed via $.post and then I append that data to the my page (the output of what happens) I use like 2 extra queries just to simple check how much damage the user is doing and a UPDATE query to update the monsters loss of LIFE in the mysql. And maybe 1more query to grab monster data or whatnot. I am curious though, If I use socket.io with mysql.... a user could essentially kill mobs faster because it's all done in 1 connection and they dont have to wait for the 200ms delay via AJAX. But it wouldn't really save any performance would it since it's turned based already and the queries are < 3 needed per each attack? I'm just trying to make it faster for users to hunt and kill mobs w/o having to wait for stupid little ajax requests. Thoughts? I also do random captcha's every xx amount of battles and each time a user level's up so they cannot bot or macro. Not sure if this would effect socket.io [i might be going off a tad here] Edit: also I cannot get node.js/socket.io to work with WAMP on windows, such a pain the ass man. I can prob get it working on my linux/vps box but I HATE editing/working off of my localhost... Also, I dont understand this: http://www.gianlucaguarini.com/blog/push-notification-server-streaming-on-a-mysql-database/ They're literally putting the mysql into a loop.... This is the exact same crap as a While loop in php with longpolling is it not? How can this use any less resources I mean seriously, socket.io a joke or what? Edited September 13, 2013 by Monkuar Quote Link to comment https://forums.phpfreaks.com/topic/282131-curious-if-i-should-move-to-socketio-for-this/ Share on other sites More sharing options...
kicken Posted September 13, 2013 Share Posted September 13, 2013 (edited) They're literally putting the mysql into a loop.... This is the exact same crap as a While loop in php with longpolling is it not? How can this use any less resources I mean seriously, socket.io a joke or what? Yes, it's the same thing. No, it's probably not saving any resources. It also has nothing to do with socket.io really. Socket.io is nothing more than a way for the browser and your server to communicate with each other. If you want to use less resources on your server, you need to design your scripts to use less resources. Socket.io will not help you with this problem, because it is not a problem that socket.io is attempting to solve. edit: You posted this in the wrong forum. I've moved the thread to a more appropriate forum for you. Edited September 13, 2013 by kicken Quote Link to comment https://forums.phpfreaks.com/topic/282131-curious-if-i-should-move-to-socketio-for-this/#findComment-1449385 Share on other sites More sharing options...
Monkuar Posted September 13, 2013 Author Share Posted September 13, 2013 Yes, it's the same thing. No, it's probably not saving any resources. It also has nothing to do with socket.io really. Socket.io is nothing more than a way for the browser and your server to communicate with each other. If you want to use less resources on your server, you need to design your scripts to use less resources. Socket.io will not help you with this problem, because it is not a problem that socket.io is attempting to solve. edit: You posted this in the wrong forum. I've moved the thread to a more appropriate forum for you. Well I just actually got socket.io installed and now that I think of it, this mysql stuff seems worthless now. Looks like socket.io is only good for bandwidth (chat) data packets being sent in real time across the server. If MYSQL resources the same as the while loop in php as in longpolling to socket.io mysql module, what a complete and utter waste of time this has been, lol. Although, since I got it on working on windows, I would love to query the monsters table and let my users attack the mob faster/etc. I assume this could be faster with socket.io though, but wouldn't save performance? wouldn't it save a little bit because php isn't processing any of it? Quote Link to comment https://forums.phpfreaks.com/topic/282131-curious-if-i-should-move-to-socketio-for-this/#findComment-1449386 Share on other sites More sharing options...
gizmola Posted September 13, 2013 Share Posted September 13, 2013 Web servers have keep alives. By setting the keep alive to a conservative value -- perhaps 15-30 seconds or more, these types of interactions would essentially occur within the same TCP connection so long as a player was continuing to make plays, however if a turn is occuring in 200ms, then you're trying to micro optimize and adding complexity. This article does a really good job of talking about the options with query clientside script examples: http://techoctave.com/c7/posts/60-simple-long-polling-example-with-javascript-and-jquery Quote Link to comment https://forums.phpfreaks.com/topic/282131-curious-if-i-should-move-to-socketio-for-this/#findComment-1449389 Share on other sites More sharing options...
Monkuar Posted September 13, 2013 Author Share Posted September 13, 2013 (edited) Web servers have keep alives. By setting the keep alive to a conservative value -- perhaps 15-30 seconds or more, these types of interactions would essentially occur within the same TCP connection so long as a player was continuing to make plays, however if a turn is occuring in 200ms, then you're trying to micro optimize and adding complexity. This article does a really good job of talking about the options with query clientside script examples: http://techoctave.com/c7/posts/60-simple-long-polling-example-with-javascript-and-jquery Yeah, well 200ms is mostly the time the user has to wait per ajax request. (Server lag) and I disable the user to attack via server side with php sessions and javascript 1 time each 2 seconds [so I can optimize queries and save em better] But now that I got this cool socket.io stuff, I'm thinking of dodging all this "2 second" per attack and just let the user click click click click click as fast as he needs and also I could put in Attack Speed % too. [Would need to validate it somehow serverside ofcourse, not sure how] but would be easier to do it with socket.io. For example, user has 20% attack speed, he could press the attack button faster than someone with 10% attk speed [like 300ms faster] or something lol iuno. [it's just a text based game, nothing fancy like swinging swords or whatnot] But im really looking forward for the chat system now, since I never knew we don't need to store/update them in mysql. [Can just be data over the connection] My problem is, what if a user accidentally closes the browser and comes back? all the data and chat logs will be gone, I need a temporary solution to hold like the last 10-20 lines in a cookie or something. [same logic as if ur character goes to the character selection screen and comes back] if all your whispers or whatever is gone, it would seem weird :/ Edited September 13, 2013 by Monkuar Quote Link to comment https://forums.phpfreaks.com/topic/282131-curious-if-i-should-move-to-socketio-for-this/#findComment-1449390 Share on other sites More sharing options...
martov Posted November 18, 2013 Share Posted November 18, 2013 hm about the chat prob something like HTML5 web storage ? Quote Link to comment https://forums.phpfreaks.com/topic/282131-curious-if-i-should-move-to-socketio-for-this/#findComment-1458895 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.