KnowSkill Posted August 12, 2015 Share Posted August 12, 2015 I am looking to develop a cross platform chat app for mobile devices (iOS and Android) is it a poor decision to build the app where every few seconds it hits a php page that asks for the most recent messages in the db that contain the 2 users? Quote Link to comment https://forums.phpfreaks.com/topic/297762-php-chat-mysql-bad-practice/ Share on other sites More sharing options...
QuickOldCar Posted August 13, 2015 Share Posted August 13, 2015 You should use websocket for a chat, constant polling php is too much usage for the server. http://socket.io/get-started/chat/ http://tutorialzine.com/2014/03/nodejs-private-webchat/ http://www.sanwebe.com/2013/05/chat-using-websocket-php-socket You can search for others, this is the basic idea. Quote Link to comment https://forums.phpfreaks.com/topic/297762-php-chat-mysql-bad-practice/#findComment-1518663 Share on other sites More sharing options...
KnowSkill Posted August 13, 2015 Author Share Posted August 13, 2015 Is this how apps like Tinder build the chat side of their app? Quote Link to comment https://forums.phpfreaks.com/topic/297762-php-chat-mysql-bad-practice/#findComment-1518719 Share on other sites More sharing options...
scootstah Posted August 13, 2015 Share Posted August 13, 2015 Yes, pretty much any real-time chat system is going to use TCP sockets. With a TCP connection, a client connects to a server and the connection remains open, or, "persistent". Data is more-or-less only sent one way or the other when something happens, like when a chat message is sent. If you do not use a persistent connection, and instead rely on polling, then you have to request data at continuous intervals even if there is no data to give. In such a system the messages will not be in real time, either, and will only be received when the client asks for them. Now, if there is not going to be a web component then there is no point using WebSockets. You're better off just using straight up TCP protocol if you don't need web chat. And I wouldn't use PHP either, it's not really good at that. Java or NodeJS would be better choices. Quote Link to comment https://forums.phpfreaks.com/topic/297762-php-chat-mysql-bad-practice/#findComment-1518723 Share on other sites More sharing options...
KnowSkill Posted August 14, 2015 Author Share Posted August 14, 2015 The chat will only be used from the apps that I develop for Android and iOS. Quote Link to comment https://forums.phpfreaks.com/topic/297762-php-chat-mysql-bad-practice/#findComment-1518741 Share on other sites More sharing options...
QuickOldCar Posted August 14, 2015 Share Posted August 14, 2015 Doesn't matter what or how you access it, the point is the chat server itself doing the work and able to do it. Quote Link to comment https://forums.phpfreaks.com/topic/297762-php-chat-mysql-bad-practice/#findComment-1518748 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.