Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Socket Commands for HTML5

Author
Message
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 20th May 2016 20:38 Edited at: 20th May 2016 20:47
Someone got it working ?

Im interested in a chat room thing in HTML5
Must I host an extra app on my server where all clients connect to it
Or can I somehow find the first "player" who then hosts a room for my chat

What I got:


It sends values from -128 to 127 to the same app
(in this case 192.168.1.2)
(did it in 30 mins)

Using AGKv2 Tier1
BatVink
Moderator
20
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 21st May 2016 16:11
Quote: "Or can I somehow find the first "player" who then hosts a room for my chat"


If that person leaves, the chat will end.
You should host the chat on your web server.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 21st May 2016 18:32 Edited at: 21st May 2016 19:53
You are right and it is less of a hassle
Do you know how that Web Sockets thing works ?
Can't get the HTML5 version to receive packets with my Code

Using AGKv2 Tier1
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 22nd May 2016 21:45
WebSockets work slightly differently to sockets on other platforms. Normally you'd connect with ConnectSocket() and then be able to send and receive data without doing anything else. However when an HTML5 app calls ConnectSocket() it starts with the normal TCP connection process, so the app on the other end will see a valid socket connection, but then the HTML5 app will send some data (roughly 500 bytes of it) without you doing anything. This is the request header from this page, the device at the other end of the connection must send back the response text before HTML5 app will complete the socket connection.

I decided to try it out for myself, here's what I came up with.
Server, run on a non-HTML5 platform


Client, run on HTML5


After that I tried sending raw data as you would a normal socket but it didn't like it, it just disconnected. I heard something about WebSocket message frames, so maybe it has another special format for those, but I didn't investigate further.
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 22nd May 2016 22:34
Wow thank you,

I will try it tomorrow and investigate in websocket message Frames ..
Maybe put the example in the help files

Using AGKv2 Tier1

Login to post a reply

Server time is: 2024-03-28 17:31:18
Your offset time is: 2024-03-28 17:31:18