Multiplayer tutorial 2: chat room

Favourite 88 favourites
Tutorial written by AshleyOriginally published on 14th, March 2014 - 3 revisions

This tutorial assumes you have already read Multiplayer tutorial 1: concepts.

The easiest introduction to the multiplayer object in Construct 2 is a simple chat room. This only has to deal with connecting and joining the room, other peers joining and leaving, and relaying simple chat messages. Some of the more complicated topics like input prediction and lag compensation are simply not necessary since there is no object the player controls. These will be covered in the next tutorial, but for now we can focus on the basics and still produce something useful.

To get going, open the Example: Multiplayer - chat room example that comes with Construct 2. This can be found in the Select template or example dialog that opens when pressing File - New. While this example is already commented, this tutorial will explain it event-by-event in more detail, since some of the features take a little more explaining than is convenient in event comments.

Running and testing

To preview the example, you must run it from the first layout (F4). If you run the Chat layout directly, it will not be able to join the chat room, since it needs a valid name entered from the Login layout.

When testing the tutorial multiplayer games, it's possible you will meet other people who happen to be running the tutorial at the same time. However users commonly go "away from keyboard" (AFK) and leave things running without attending to them, so don't be surprised if other people are present but don't respond to chat messages. If you don't happen to meet someone active, get a friend involved and do some testing with them!

It's also possible someone will already be hosting the tutorial but you won't be able to connect to them. If that happens, change either the game, instance or room name and you'll start a new game which you host yourself.

Share and Copy this Tutorial

You are free to copy, distribute, transmit and adapt this work with correct attribution. Click for more info.


sakugoku 368 rep

Can I connect to another server? as local servers. If you can do it "wss: //" instead of what I wrote. (I have personal edition)

Tuesday, April 26, 2016 at 11:19:56 AM
Poxnixles 574 rep

Anyway I can get all players in the same chat room to move to a different layout together, preventing further joins?

Saturday, April 30, 2016 at 3:17:44 AM
Poxnixles 574 rep

@ashley though also, I can't get seem to have others join the room I host?

Saturday, April 30, 2016 at 3:47:32 AM
Virenz 233 rep

I am getting a few errors, is it possible you could link a download link for the project so i can see what i am doing wrong? Thanks!

Monday, August 08, 2016 at 12:02:42 PM
Virenz 233 rep

I copied everything you did (including newline) but my text does not go to the new line :(

Monday, August 08, 2016 at 3:10:32 PM
2Dpysics 213 rep

When testing the tutorial multiplayer games, it's possible you will meet other people who happen to be running the tutorial at the same time.

Yes... Kkkkkkkkkkkkkkk I'm a victim

Monday, June 26, 2017 at 2:50:22 PM
2Dpysics 213 rep

I've changed a little the project, without changing on "signalling" group and now I just connect as a peer

Monday, June 26, 2017 at 4:41:50 PM
2009antz2009 393 rep

Ok, i may be missing a step. but on line 8 when it asks to enable a group named "host" but a group named "host" was never created... am i missing something important here?

Friday, June 30, 2017 at 9:10:13 AM
Haybale333 358 rep

OMIGOSH! THIS IS SO COOL! THANKS, ASHLEY!!!!!!!!!!!!!!!! wish i could understand it more :P

Sunday, August 27, 2017 at 6:30:54 PM
renatinhocogen 207 rep

Sorry, guys!

I tried the chat room tutorial in Construct 3. It keeps forever "Connecting on server...." and thats all....The "Is connected to signal....." never is trigged.......

Someone knows what am I doing wrong? Thanks!

Saturday, February 24, 2018 at 7:05:59 PM
Konstantin313 257 rep

is there any way to change the server you are using ? this server "wss://" i want to change it .. i need to buy one for my own ! so no one can join until he is running it from my website or downloaded it ! and if yes where i can buy a server ? does scirra selling servers ?

Monday, May 21, 2018 at 10:28:53 PM

Leave a comment

Everyone is welcome to leave their thoughts! Register a new account or login.