How does Omegle work?

Sorry for the vague question, but Omegle has exactly what I want for my site. This is a bare chat system. You send and receive messages instantly. I spent today looking for a crickbox method, but all I could find were people who say to use MySQL and javascript intervals for validation. Omegle is instantly updated with new messages. How does it all work?

+5
source share
2 answers

You should read this wikipedia article , this will give you a better idea of ​​the process.

The main keywords here are long polls, websockets, flash sockets.

, ( ), node.js + socket.io shine.

+11

. , , , ( #, PHP). HTTP- GET, :

GET /chat?room=someroom&me=Jerod HTTP/1.1

( TcpClient , Dictionaty<string, Dictionary<string, TcpClient>> clients;, : clients["someroom"].Add("Jerod", tcpClient); , Jerod)

POST, , :

POST /chat?room=someroom&me=Sara HTTP/1.1
Content-Length: 2

Hi

, , Sara "" "someroom". Jerod's GET , , , , ( - ) :

HTTP 200 OK
Content-Length: <length>

Sara: Hi

GET XMLHttpRequest (AJAX GET), -, 0 ( ), , .

POST XMLHttpRequest, .

AJAX (GET) , , ( "Sara: Hi" ), DIV, GET, , - ...

AJAX (POST), DIV, - , , , JS: document.getElementById("chat").innerHTML += uname+": "+txt;

.

+4

All Articles