Chromium Blog
News and developments from the open source browser project
Play Cube Slam, a real-time WebRTC video game
Wednesday, June 12, 2013
Cube Slam
is a Chrome Experiment built with
WebRTC
, an open web technology that lets you communicate in real-time in the browser (and in this case, play an old-school arcade game with your friends) without downloading and installing any plug-ins. In this post, we wanted to explain a bit about how Cube Slam works.
Cube Slam uses
getUserMedia
to access your webcam and microphone (with your permission, of course),
RTCPeerConnection
to stream your video to a friend, and
RTCDataChannel
to transfer the bits that keep the gameplay in sync. If you and your friend are behind firewalls,
RTCPeerConnection
uses a
TURN
relay server (hosted on Google Compute Engine) to make the connection. However, when there are no firewalls in the way, the entire game happens directly peer-to-peer, reducing latency for players and server costs for developers.
Cube Slam is the first large-scale application to use
RTCDataChannel
, which provides an API similar to
WebSocket
, but sends the data over the
RTCPeerConnection
peer-to-peer link.
RTCDataChannel
sends data securely, and supports an "unreliable" mode for cases where you want high performance but don't care about every single packet making it across the network. In cases like games where low delay often matters more than perfect delivery, this ensures that a single stray packet doesn't slow down the whole app.
RTCDataChannel
supports unreliable mode in desktop Chrome today. We're working on implementing the latest
WebRTC spec
, where we'll use the standard
SCTP
protocol to support reliable mode as well. WebRTC will also be available on Chrome for Android later this year, and you can
try it now
by flipping “Enable WebRTC Android” in chrome://flags. Several browsers are currently working on implementing WebRTC, and we’re looking forward to the day when you can have a Cube Slam face-off against your friends on any browser and any device.
To learn more about the tech in Cube Slam, you can check out our
technology page
and
source code
. Disable the shields! Destroy the screen! Have fun!
Posted by Justin Uberti, Software Engineer and Channeler of Data
Labels
accessibility
1
benchmarks
1
beta
1
blink
1
chrome apps
3
Chrome Frame
1
chrome web store
26
chromeframe
3
chromeos
3
chromium
3
cloud print
1
dart
8
devtools
11
extensions
23
gdd
1
googlechrome
12
html5
11
incognito
1
javascript
3
linux
2
mac
1
mobile
2
na
1
native client
8
New Features
5
octane
1
open web
2
releases
2
rlz
1
security
30
spdy
2
ssl
2
v8
5
web intents
1
webaudio
3
webgl
7
webkit
5
webp
5
webrtc
4
websockets
5
webtiming
1
Archive
2017
Jun
May
Apr
Mar
Feb
Jan
2016
Dec
Nov
Oct
Sep
Aug
Jun
May
Apr
Mar
Feb
Jan
2015
Dec
Nov
Oct
Sep
Aug
Jul
Jun
May
Apr
Mar
Feb
Jan
2014
Dec
Nov
Oct
Sep
Aug
Jul
Jun
May
Apr
Mar
Feb
Jan
2013
Dec
Nov
Oct
Sep
Aug
Jul
Jun
May
Apr
Mar
Feb
Jan
2012
Dec
Nov
Oct
Sep
Aug
Jul
Jun
May
Apr
Mar
Feb
Jan
2011
Dec
Nov
Oct
Sep
Aug
Jul
Jun
May
Apr
Mar
Feb
Jan
2010
Dec
Nov
Oct
Sep
Aug
Jul
Jun
May
Apr
Mar
Feb
Jan
2009
Dec
Nov
Sep
Aug
Jul
Jun
May
Apr
Mar
Feb
Jan
2008
Dec
Nov
Oct
Sep
Feed
Google
on
Follow @ChromiumDev
Give us feedback in our
Product Forums
.