views:

108

answers:

4

Hey guys.

I'm building a website where I hook people up so that they can anonymously vent to strangers. You either choose to be a listener, or a talker, and then you get catapulted into a one-on-one chat room.

The reason for the app's construction is because you often can't vent to friends, because your deepest vulnerabilities can often be leveraged against you later on. (Like it or not, this is a part of human nature. Sad.)

I'm looking for some insight into how I should architect everything. I found this neat tutorial, http://giantflyingsaucer.com/blog/?p=875, which suggests using python & stackless + flash. Someone else suggested I should try using p2p sockets, but I don't even know where to begin to look for info on that.

Any other suggestions? I'd like to keep it simple. :^)

+1  A: 

Flash is user-unfriendly for UI (forms, etc) and it is relatively easy to do what you want using HTML and Javascript on the front-end.

One possible approach for reading the messages would be to regularly do an Ajax request from the server for any new messages. Format the new message and insert it into the DOM.

You will probably need to answer at least these questions before you continue, though:

1) Are you recreating IRQ (everyone sees your posts), or is this a random one-to-one chat, like chatroulette?

1a) Is this a way for a specific person to talk to another specific person, or is this more like twitter?

2) What is your plan for scaling up if this idea takes off? Memcached should probably be a method of last-resort ("bandaid over a bullet-hole"). What's your roadmap for eventually handling a large volume of messages?

3) Is there any way to ignore users? Talk to certain users? Hide your rants from users?

BryanH
Oh, what if you used the twitter API to do what you wanted? Hmm....
BryanH
1) It's random one-to-one chat. 2) Do you have any suggestions for what software to power the backend?
Zachary Burt
http://www.google.com/search?q=chat+application+github
BryanH
+3  A: 

Unless you expect super high load, this is simple enough that it doesn't really matter what you use on the backend: just pick something you're comfortable with. PHP, Python, Ruby, Even a bash script using CGI - your skill level with the language is likely to make more difference that the language features themselves.

redtuna
Let's say I write in PHP. How would I architect the backend? That's the part I don't understand :) Thanks!
Zachary Burt
I mean, I could have a mysql table to serve as the queue of listeners, and a mysql table to serve as the queue of talkers, but I don't know how to implement the peer-to-peer messaging.
Zachary Burt
I guess i could just store each message in a mysql table, and then delete it once it gets sent out to the chat partner.
Zachary Burt
+1  A: 

Hey Zach I had to create a socket server for a flash game I made. I built my server in C#, but I would use whatever language your familiar with. If you let me know what your most comfortable with I could try to help find a good tutorial.

The one thing I spent many hours on was getting flash to work from a website with a socket server. With the newer versions of Flash you need to send back a policy file. In my case this needed to be the first chunk of data sent back to the client when they connected to the socket server.

Not sure what to tell you about structuring the back end. I need to know a little bit more about your programming experience. I had an array of all user connections, and was placing them in different "Rooms" so they could play each other. So just some simple arrays and understanding how to send messages to the clients would help you here.

If you have any familiarity with C# I would have no problem sending you the source code for my socket server.

Joshua Jewell
+2  A: 

I would use an XMPP server like ejabberd or OpenFire to power the backend. XMPP contains everything you need for creating chat/real-time applications. You can use a Flex/Flash Actionscript library like Actionscript 3 XIFF to communicate with the XMPP server.

Abhinav
You can use the StropheJS library for doing the same thing in Javascript. http://code.stanziq.com/strophe/
Abhinav