chat

PHP Comet. How to do it better?

时光怂恿深爱的人放手 提交于 2019-12-04 11:24:54
I have a simple comet chat. JavaScript send ajax request with long polling. When server find new messages in the database, it answers and gives JSON. Next, JavaScript send the request again. Javascript: function cometConnect(){ $.ajax({ cache:false, type:"get", data:'ts='+ts, url: urlBack, async: true, success: function (arr1) { //work with JSON //..... }, complete:function(){ cometConnect(true); nerr=false; }, dataType: "text" }); } PHP $flag=true; $lastmodif = isset($_GET['ts']) ? $_GET['ts'] : 0; while($flag){ $q=mysql_query("SELECT text, posterId,modified, fromUserId,toUserId, login FROM

Simple PHP long polling chat script, too simple?

给你一囗甜甜゛ 提交于 2019-12-04 11:17:26
问题 Im working on a simple chat app, probably 10 to 20 users per room. The Script that queries the database for new messages looks too simple for all the request it'll be getting. Below is the block of code that loops for new messages, the rest of the script is just getting the variables, construction of the query and the json response object: $sleepTime = 1; //Seconds $data = ""; $timeout = 0; //Query database for data while(!$data and $timeout < 10){ $data = getQuery($sql); if(!$data){ //No new

file() [function.file]: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution

為{幸葍}努か 提交于 2019-12-04 10:59:04
I got the following error when I get contents from file(" http://www.otherdomain.com "). file() [function.file]: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution The domain server is linux. How to resolve this problem? Quoting: If you're having problems with fopen("url...") but you can run 'host url' in a shell window and get the correct lookup, here's why... This has had me banging my head against it all day - finally I found the answer buried in the bug reports, but figured it should really be more prominent! The problem happens when you're on an ADSL line

didReceiveRemoteNotification not being called when I tap on app icon after receiving a push notification while on background

柔情痞子 提交于 2019-12-04 10:30:58
问题 When my app is on background and I receive a remote notification, two things can happen: I tap on the push notification banner, my apps comes to foreground and didReceiveRemoteNotification is called. I tap on my app icon from the springboard, my app comes to foreground and didReceiveRemoteNotification IS NOT called. So, in the scenario 1, I can update my counter of unread messages inside the app in response to didReceiveRemoteNotification. In the scenario 2, I can't. How can I solve this

Sending Pictures like WhatsApp

荒凉一梦 提交于 2019-12-04 07:46:30
I have made a chatting application. I want to add photo/file sharing concept in my application same as WhatsApp. I have made the app using Xmpp/Openfire and current now I am using this function for photo sharing, but it is not all reliable : public void sendFile(final String path, final String receiver) { Thread thread = new Thread() { public void run() { ServiceDiscoveryManager sdm = ServiceDiscoveryManager .getInstanceFor(connection); if (sdm == null) sdm = new ServiceDiscoveryManager(connection); sdm.addFeature("http://jabber.org/protocol/disco#info"); sdm.addFeature("jabber:iq:privacy"); /

socket.io chat with private rooms

徘徊边缘 提交于 2019-12-04 07:35:16
问题 I started looking into node and socket.io. I already have created a simple chat application and I am amazed at how easy it was. Now, I would like to take a little bit further and provide a list of online users that have the ability to chat with each other in private. What would be the best way to approach this? I read on 0.7's new room feature. Would that be a way to go? Dynamically create a new room each time 2 users need to chat in private? But how the second user is going to be notified of

How to run a background thread in ruby?

南笙酒味 提交于 2019-12-04 07:29:05
I am new to ruby and thought it would be a great idea to rebuild a simple chat program I made in C#. I am using Ruby 2.0.0 MRI (Matz’s Ruby Implementation). The problem is I want to have I/O for simple server commands while the server is running. This is the server that was taken from the sample. I added the commands method that uses gets() to get input. I want this method to run as a thread in the background, but the thread is blocking the other thread. require 'socket' # Get sockets from stdlib server = TCPServer.open(2000) # Socket to listen on port 2000 def commands x = 1 while x == 1

Where can I get a PHP / MYSQL chat room application [closed]

让人想犯罪 __ 提交于 2019-12-04 07:12:04
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . My question is an elaboration of this one: PHP/MYSQL AJAX Chat I have a 100 chat rooms which I need to make. Is there a php/mysql based chat system that would do something like this? phpFreeChat is mentioned, but from what I understand, I have to (manually) download and install the application 100 times in

Making Android chat application from scratch

会有一股神秘感。 提交于 2019-12-04 05:29:14
问题 I need to make chat application for android. I thought of using PHP script to implement the chat application. Basic idea is to send message form android client to PHP script and making use of PHP script send the messages to the MySQL database. These messages will be broadcasting to other people. But the problem is auto broadcasting messages to other people. Is there a way to do this using android and php? 回答1: You can do the following Make a persistent tcp connection between your device and

Bubble Chat issue Android listview

送分小仙女□ 提交于 2019-12-04 05:19:39
问题 Hi i am having a strange trouble, i am not gettings bubble for example you messeges on right and mine on left... when ever i call notifydatachanges it erases all the bubbles...plz guide me. below is the code... private final Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { if(D) Log.d(TAG, "In the Handler"); switch (msg.what) { case PACKET_CAME: String incomingMessage = (String) msg.obj; receivedMessages.add("You: " + incomingMessage); mg = new Message();