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.


dynamiczny 442 rep

Is there any chance to obtain the signalling server code, so we could use our own signalling server?

Tuesday, March 25, 2014 at 2:22:37 PM
DavidA13 1,403 rep

Where can I get the SCROLL TO BOTTOM action for a text object (seen on page 3 of this tut!), I can't find it a new action in the latest BETA release or am I missing something? Thanks.

Tuesday, March 25, 2014 at 3:09:51 PM
AbelaNET 14.9k rep

Thanks for sharing

Wednesday, April 02, 2014 at 8:21:19 AM
CarHazy 4,520 rep


Could you elaborate more on that private message thing? I'm having a little trouble setting it up.


Tuesday, April 15, 2014 at 12:40:14 AM
CarHazy 4,520 rep

Would you happen to have an example?

Tuesday, April 15, 2014 at 12:40:26 AM
garymocock 580 rep

hello, great tut by the way. helped me out loads. I was wondering on a few things and how they could be implemented into our projects..

Multiple rooms - I have it set up but now I can only send messages in one room not the others.

Private message - not even tried yet but feel it would be important for a chat room.

User Media - take picture's or video's - send to main chat or in private

Create profiles - will learn the more I play with C2

Log In With password - think I know but would like to know how to create a Wss before I start on this

Keep up the good work and thank you for providing us with this its help alot

Tuesday, April 22, 2014 at 11:23:43 PM
garymocock 580 rep

just so you know I have made rooms but get kicked when a peer joins after a few seconds and both host and peer get kicked...

also have live webcam in each room for peers and host

Wednesday, April 23, 2014 at 5:03:45 PM
Tylermon 2,990 rep

I would be very interested in a signaling server tutorial.

Friday, April 25, 2014 at 8:13:18 PM
Scofano 2,765 rep

I keep getting kicked out. :(

Sunday, April 27, 2014 at 4:50:52 AM
Daggio 5,331 rep

this tutorial is great! thanks for writing this :D

Friday, May 02, 2014 at 12:56:46 PM
jaycode 202 rep
@Ashley - say my game can only work well with 2 players i.e. one host and one peer - is there anyway I can limit my multiplayer sessions to 2 players only?
quoted from exertia

in the join events there is a option called max peers, which sets the max players

Sunday, June 22, 2014 at 9:56:38 PM
suntank 1,556 rep

I noticed if I do not change the room from "default" to something else, peers get disconnected every time while testing locally (host does not). not that this is a huge deal, but I'm wondering why that is?

Friday, July 04, 2014 at 1:28:27 AM
suntank 1,556 rep

I apologize, i meant the "instance"

Friday, July 04, 2014 at 2:18:08 AM
sourabh kha 154 rep

[Hyperlink removed - users with less than 500 rep cannot post links]
guyzz open this link, create account n you can make money's true

Saturday, July 12, 2014 at 7:26:52 AM
sourabh kha 154 rep

[Hyperlink removed - users with less than 500 rep cannot post links]
open this link create account n you can make money it's true..

Saturday, July 12, 2014 at 7:32:03 AM

Leave a comment

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