Websocket Chat Example

Show us your completed creations made in Construct 2

Post » Wed May 08, 2013 6:35 pm

My new example for using Websockets.

Here is the game :)

In the process of writing a tutorial! Will post here when done.

Can someone test this please? It worked when me and my friend uses it (we live about 10 miles apart) bu I noticed that the play count has gone up, but my server isnt showing any new connections. What should happen is:

You choose a username
You come to a list box with no text in it. As people send messages, the box will fill up
You send messages by typing in the textbox at the bottom and hitting ENTER

Can you please post here if it doesnt work for you?marlon6672013-05-10 07:12:34
B
10
S
2
Posts: 94
Reputation: 1,536

Post » Fri May 10, 2013 7:12 am

BUMP. Edited OP.
B
10
S
2
Posts: 94
Reputation: 1,536

Post » Tue May 21, 2013 8:25 pm

Looks cool, this is something like I am looking for, a simple chat. Do you know how long before the tutorial or files will be released?
B
5
S
1
Posts: 26
Reputation: 479

Post » Tue May 21, 2013 8:57 pm

I'm trying to upload the tutorial, but for some reasin I keep getting a Server URI Error. I've asked about it, but no chanbe at the minute :/
B
10
S
2
Posts: 94
Reputation: 1,536

Post » Thu Jul 18, 2013 2:14 am

Hello! I am new to construct 2 and would like to know how web socket works? Thank you
B
6
S
2
G
2
Posts: 15
Reputation: 1,564

Post » Fri Jul 19, 2013 9:48 pm

Hi BasicUser :)

Sorry, I took down the example because i couldnt keep my computer running all the time. To start using Websockets, you need a server application running on your computer, then you need to poimt your C2 app to it using the Websocket object.

C2 does not include a way for coding a server but you can find many open source implemenrations on Google.

The basics of using web sockets is using text messages to communicate with the server. You will need to write your own logic in the client and rhe server as to how your messafes are interpreted. you can find many examples of this on Google :) hope this helps!
B
10
S
2
Posts: 94
Reputation: 1,536

Post » Sat Jul 20, 2013 9:13 am

@marlon667 I'm still confused, I tested with http://www.websocket.org/echo.html to connect with your .capx example, it doesn't do anything.

I'm still unaware how to use websocket, I have zero knowledge how to use websocket, but not at all, I know how to use php in server, but websocket is different...

Would you explain step by step? then do you know some free hosting services include websocket?

Thanks!
B
95
S
25
G
20
Posts: 3,052
Reputation: 22,613

Post » Sat Jul 20, 2013 10:20 am

@Joannesalfa, I tried numerous times to post a tutorial to go with this example, but I kept getting a Server URI error. I think it has something to do with the Scirra Website, I'm not sure, but I took my example down because I had AS exams and I couldn't leave the server running on my computer.

Here is the basics of WebSockets:
WebSockets are upgraded HTTP requests that need a specialised server application to handle them. You can create one yourself, or use an existing Websocket server as a base. I originally used a Node.JS implementation, but I switched to C# for better SQL support.

The test at http://www.websocket.org/echo.html is essentially the same as my .capx file in the sense that it is just a client application. You need to open a Websocket connection to a server application to enable communication.

There are no hosting services that provide Websocket services per se. A Websocket server is a stand-alone application that you connect multiple clients to.

If you wanted to work with my example .capx, here's a few things that will help:

This is a server implementation in C# that I use. The base server allows you to listen for connection requests on a port that you choose, and then accept connections and incomming messages for each connection. What you want to do with those messages is something you have to write yourself.

In my example .capx, I believe there is a global variable containing the location of the websocket server. If you are running the server on the same computer you use the client, change the server location to localhost. That way you can send messages to your server.

If you need anymore help, reply here :) I'm gonna try my tutorial again, this seems like a problem for a few people.
B
10
S
2
Posts: 94
Reputation: 1,536

Post » Sat Aug 24, 2013 6:05 pm

@marlon667
I can't find .capx of your chat! Where is it?
B
23
S
4
G
1
Posts: 57
Reputation: 2,065

Post » Sun Aug 25, 2013 2:49 pm

@sergyperov

I took down my example, as I couldn't leave my computer on all the time to host the server. It will go back up soon, but I have to focus on starting my Computing project for my A2. I will put it back up soon, however, hopefully with a video tutorial :)

On that note, I might as well add that I'm working on a bit Websocket project for my A2 Computing coursework, and when I start, it will be on Github :) I'll post my repo here when I get it up
B
10
S
2
Posts: 94
Reputation: 1,536

Next

Return to Completed Creations

Who is online

Users browsing this forum: Andrew6321 and 1 guest