Documentation of the Omegle Protocol

Posted: 22nd June 2010 by Andrew Brown in Nonfiction, Tutorials
Tags: ,

Synopsis

Omegle is a website that connects two anonymous strangers together and allows them to have a “no strings attached” conversation. Behind the Omegle uses several PHP pages for its back-end that must be accessed with HTTP POST requests. Each page has a different function, must be passed specific parameters, and returns specific data. All files are located in the root directory and can be accessed at http://www.omegle.com/example-page-name.

The Pages

/start

This page initializes your Omegle session. No parameters need to be passed, but the page should be accessed with a POST request. The page will respond with your six-character Omegle ID encased in quotation marks (“fn8Hkg”). This ID is randomly generated and lasts for the entirety of a conversation. It is composed of the characters a-z, A-Z, 0-9, underscores, and hyphens.

On the server side, accessing this page adds a row in the users table with your Omegle ID and a value indicating that you are not currently in a chat, which allows you to be paired up with someone of similar status. It also affects the count of users online, which is visible on the Omegle homepage.

/count

This page requires no parameters to be passed and can be accessed with a GET or POST request. It returns the current number of users online by counting the current number of rows in the users table. This value can be seen on the Omegle homepage.

/events

Parameter Value
id Your Omegle ID

The events page is constantly accessed by the Omegle front-end to look for updates in the conversation. It must be accessed in a POST request with your Omegle ID set in the id parameter. Connections, disconnections, messages, and notifications are all sent through the events page. The output is formatted as JSON and will need to be parsed as such. An example output is below:
[["waiting"], ["connected"], ["typing"], ["gotMessage", "Welcome to Omegle!"], ["strangerDisconnected"]]

The full list of events that can be passed through this page is as follows:

Event Type Parameter Explanation
waiting Always the first message, this event indicates that your Omegle ID is valid.
connected This event signifies that you have been connected to a stranger.
typing This is a toggle switch; it is shown when the user begins typing and again when they are finished typing. It is automatically toggled off with a gotMessage event.
gotMessage message This event contains messages from the stranger you are chatting with. In addition to relaying their message as a parameter, it also toggles off whether or not they are typing (normally set through the typing event).
strangerDisconnected This event signifies that the stranger you were chatting with has disconnected.

If no new events have occured, the word null is displayed.

/typing

Parameter Value
id Your Omegle ID

Whether or not a user is typing is used as a switch in the Omegle back-end. Accessing this page for the first time toggles your status to on, which means you are typing. Accessing it again toggles your status to off. Both times, an event is sent to whom you are chatting with to signal the change. Note that your typing status automatically switches to off when you access the send page.

/send

Parameter Value
id Your Omegle ID
msg The message to send to your chat partner

The purpose of this page is to allow users to send messages to those they are chatting with. The page must be accessed with a POST request and requires two parameters to be set: id and msg. There is no return value from the server. This page also toggles your typing status to off. The message is written to the msgs table and read later by the /events page.

/disconnect

Parameter Value
id Your Omegle ID

This page disconnects you from your current conversation and alerts the person with whom you were chatting with of the disconnection. It must be accessed with a POST request and passed your Omegle ID as the id parameter. This will remove all rows in the users table matching your Omegle ID.

  • Moodee

    Interesting article, but I have a question. How does the script knows when someone closes the browser window. When is the user’s row deleted from the database table?

    • http://www.drusepth.net Andrew Brown

      Good question. I’ll take a look again at the updated software and get back to you asap. In the meantime, there might be a hint in the Javascript: http://bajor.omegle.com/static/omegle.js

  • http://www.drusepth.net Andrew Brown

    Good question. I’ll take a look again at the updated software and get back to you asap. In the meantime, there might be a hint in the Javascript: http://bajor.omegle.com/static/omegle.jshttp://bajor.omegle.com/static/omegle.js

  • Mayank

    Thanks a lot :)