开发者

Creating a chat feature?

I need to include chat, in my application. People sign in the chat and create their user and chat to other users. However it needs to be like facebook chat or pingchat where you add friends you want to talk to.

Can anyone give me pointers to what i need to do? I've heard about开发者_高级运维 xmpp servers but not sure if that is the right thing for my app. Any help would be much appreciated

Thanks


Is your app going to create new users, and add them in the chat list, or going to use existing users (like Gtalk, Y! Messenger etc) on existing protocols (like IRC, XMPP etc)...?

If you are going to implement your own chat system, where your users are registering in your website, then you are going to do these things:

  1. Setup your website
  2. Create a protocol (that's, how you pass messages)
  3. Write and implement an API (in PHP, ASP etc)
  4. Connect that API with your iPhone app.

How it works?

You keep a table of chat messages. The table include:

  1. Chat_From
  2. Chat_To
  3. Chat_Message
  4. Timestamp

All what you do is, when you start a Chat session from Alice to Bob, you just enter them in the table. Next, you fetch the row from the Web Server to your App, by calling your PHP file (say, http://mychatserver.com/getChat.php) based on the condition SELECT CHAT_MESSAGE FROM CHAT_TABLE WHERE CHAT_FROM="ALICE" AND CHAT_TO="BOB";. This message is displayed in your App.

This process should be performed repeatedly, with an interval of, say 1 sec.

I hope you got this idea.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜