GameCast.dev makes high performance browser-to-browser communication easy, even when transmitting across the globe. GameCast.dev works on desktops and laptops, phones, tablets & smart TVs running iOS, Android, MacOS, Windows and more.
API v1 is the quickest way to get your multiplayer game up and running. It enables broadcasting of messages to all players in your game. This is good for Massively Multiplayer Online Games (MMO) style games or simply getting your game working inside a single room. Once you have mastered this API you can move on to API v2 if your game needs multiple rooms.
To use the API in your own game, simply add this JavaScript to your game's code:
<script type="module"> import { gcOpen, gcSendFast, gcOnReceive } from 'https://gamecast.dev/gamecast-dev-v1.js' gcOpen(() => { gcOnReceive(msg => alert('Message received from another player!')) document.querySelector('button.v1').onclick = () => { gcSendFast('Hello! Test button pressed by another player.') alert('Sent a message to all other players viewing this page!') } }) </script>
The above code is already running in this webpage. Click here to open another browser window to test the code:
Note that messages are sent as fast as possible and with minimal latency so you can code the best possible browser based realtime action games. As a consequence, messages may be occasionally dropped, be received out of order, or be received as a duplicate. You need to design your netcode logic to accomodate for these conditions.
This version introduces rooms. Rooms are needed when your game plays best with a limited numbers of players in each game. You can create a room and players will be able to join the room until it is full. When all available rooms are full, a new room is spawned. Group of players will now be playing together in their own rooms.
Players inside a room can send messages to each other. Players outside of the room cannot listen to those messages. No messages can be sent or received until your player has joined a room.
To use the API on your own webpage, add this JavaScript:
<script type="module"> import { gcOpen, gcSendFast, gcOnReceive, gcRoomPublicJoin } from 'https://gamecast.dev/gamecast-dev-v2.js' gcOpen(() => gcRoomPublicJoin(2)) gcOnReceive(msg => alert('Message received from another player!')) document.querySelector('button#v2').onclick = () => { gcSendFast('Hello! Test button pressed by another player.') alert('Sent a message to all other players in this room!') } </script>
The above code is already running in this webpage. Click here to open another browser window to test the code:
Note that messages are sent as fast as possible and with minimal latency so you can code the best possible browser based realtime action games. As a consequence, messages may be occasionally dropped, be received out of order, or be received as a duplicate. You need to design your netcode logic to accomodate for these conditions.
This version introduces ultra fast, game optimised reliable messaging. GameCast.dev's reliable messaging provides the fastest possible message delivery by not imposing ordering constraints and by trading off extra bandwitdh for faster reliable messages than non game oriented reliable messaging protocols like TCP.
Reliable messaging is useful in a gaming context when you want to know, for instance, when a player has been shot by another player, or when a player has picked a certain in-game object up.
To use the API on your own webpage, add this JavaScript:
<script type="module"> import { gcOpen, gcSendReliably, gcOnReceive, gcRoomPublicJoin } from 'https://gamecast.dev/gamecast-dev-v3.js' gcOpen(() => gcRoomPublicJoin(2)) gcOnReceive(msg => document.querySelector('span.v3').textContent = `Message ${++r} received from another player!`) document.querySelector('button.v3').onclick = () => { gcSendReliably('Hello! Test button pressed by another player.') document.querySelector('span.v3').textContent = `Sent message ${++s} to all other players in this room!` } </script>
The above code is already running in this webpage. Click here to open another browser window to test the code:
Note that messages are sent as fast as possible and with minimal latency so you can code the best possible browser based realtime action games. As a consequence, messages may be occasionally dropped, be received out of order, or be received as a duplicate. You need to design your netcode logic to accomodate for these conditions.
Messages are sent reliably and with minimal latency so you can code the best possible browser based realtime action games. Messages may be occasionally received out of order.