WebSockets: What do you want?

Post your work in progress addons and get feedback

Post » Fri Sep 27, 2013 8:18 pm

I can't figure out whether it's way out of date old, days before Chrome, Mozilla etc. etc all have HTML 5 built in, or maybe just because Node.js is JS. It could be the latter. Despite the fact that Node.js has the advantage of being in JS and thus finds an audience in front-end developers, it also has the disadvantage of being in JS; which limits its capabilities.

I think I'm going to be ok giving developers the opportunity to write back-end application logic in JS; but then I'll also have the advantage of execution within Java running on the server ... so, I don't have to work around the limitations. They won't exist.

rogerfgay2013-09-27 20:19:08
B
6
S
1
Posts: 76
Reputation: 606

Post » Sat Sep 28, 2013 7:59 am

I'm not of the Node.js world, so this is taking a bit of looking around to catch on. NPM is a JavaScript helper library ... how it's described on a page I just found listing what it has. https://npmjs.org/

Obviously, I haven't tried out any of the packages. But it's an interesting idea. Some of the things mentioned ... I just thought I'd cover by having it standard kit in the game support server side; like registration, and there will definitely be messages passed back and forth. In addition, there needs to be a mechanism for pairing players in multiplayer games. I don't expect the developer to need to build that from scratch, but they will be able to customize in some way I expect.

I'm a great believer in examples and tutorials as well, and hope to have the time to do that ... and hope people who use it will write how tos. Maybe that should be part of the deal with early free adoption - the Alpha group.

I should be making a list of what needs to be supported as an outgrowth of this thread. I tend to do all that in my head when I'm working alone. I think you mentioned reading files. You can certainly send files via WebSockets or can fetch them using Ajax. So, I'm not sure what you need other than the WebSocket message or Ajax code. Would it be sufficient to provide that in a "package", or do you have something fancier in mind?
rogerfgay2013-09-28 08:03:09
B
6
S
1
Posts: 76
Reputation: 606

Post » Sat Sep 28, 2013 3:26 pm

The first thing I would look out for is security. Its all very open, and very hackable as well. There are already several npm's for different web auth's Facebook, Twitter, Google, etc. Those or others could be used to layer some defense, and would be good experience for a starter.
There are also many different npm's for making connections(Websockets etc), as well as databases.
I should say I have no idea how the file system would or even need to fit into that, as well as no idea how well Node-Webkit would work for a server.
Also working the packages in with C2's sdk will probably be an issue. In fact I'd wager it would require rewriting some to suit C2.

Then you also have to take into account the third party nature of all that, don't want to step on anybodies toes.
Image ImageImage
B
172
S
50
G
182
Posts: 8,439
Reputation: 115,097

Post » Sat Sep 28, 2013 4:51 pm

For anything regarding payment i would suggest Clay.IO i tested it.. the downside is that you have to pay 20% to them for each transaction and have to lets the user login. So if you have your own login (like i have) this is a bit of a problem but not that much. This is nice cause you don't have to handle stuff like rating, achievements, virtual items or packages, etc. You could even make use of multiplayer rooms and stuff or select the only stuff you need.

Like newt, your server must be secure. Its hard. I won't get into much details but there are basics stuff you need to know.

- Login systems. Your password must be hashed with a salt also avoid giving too much infos.. like username doesn't exist or stuff like this. This can lead to a lots of problems.
- Server flooding. You need some kind of protection against how many queries your users can send to the server. You don't want your server to hang.
- Queries validation. This is very important! I suggest implementing some kind of STATE check on the session side. Player can't send X if not in state Y.
- Queries auth token. Depend on your server.. mine got this already implemented, the server know which ones send queries based on a kind of session system. So if A send 123 then the server know its A and not B. But if you don't have such system you need to make your own. Basically, once your logged on the server send a token (hashed string) to the client and each time the client send a new query (to know he is logged in) you include this token in the query.
- Enable SSL. Your must encrypt your stuff.
- You also need to handle what happen if the query is invalid ? and question like thoses.
- Also, NEVER put any kind of client logic except drawing/display logic. This is a big mistake.. everyone can see what you send and change the internal of your javascript.

Like i said this is basic stuff you have to take care right now.Rushino2013-09-28 16:55:09
B
16
S
5
G
1
Posts: 190
Reputation: 2,489

Post » Mon Sep 30, 2013 4:04 pm

WebSockets are already pretty secure. You have to go through a "handshake" process to make a connection. Then that's your connection. Hackability is more of a systems issue. I've seen pretty good coverage on standard packages and routers, even giving specific information when someone tries to get in in the wrong way. Other things are application specific, such as when you take user input in forms to stash in a database ... easily dealt with. I've been all through this, in gory detail, while doing commercial webshops.

"Server flooding" sounds like a more innocent version of "denial of service" attacks. Yes, you'd definitely want to provide enough server power to run whatever is supposed to run. That might be a more reasonable description for a solution, rather than restricting legitimate traffic. It's also something to be considered on the economic side of things .. how much power is needed ... what's it going to cost to have big enough, or as many servers as needed?
B
6
S
1
Posts: 76
Reputation: 606

Post » Mon Sep 30, 2013 4:05 pm

Free WebSocket JavaScript Code and Tutorial
By Roger F. Gay
http://highlevellogic.blogspot.se/2013/09/free-websocket-javascript-code-and.html
B
6
S
1
Posts: 76
Reputation: 606

Post » Tue Oct 01, 2013 8:15 am

rogerfgay, I enjoyed the article. Not sure why I thought it was going to teach me how to setup a websocket server. None the less, great read!

I'm curious about your take on the WebSocket C2 manual entry section, "WebSockets and multiplayer games".
https://www.scirra.com/manual/153/websocket, section

What is a reasonable time frame to expect a client and server can constently communicate: 50 ms, 100 ms, more? Assume were talking about a client and server being in the USA.

I find this all very interesting but my coding skill is limited. I can probably figure out Python Tornado, http://www.tornadoweb.org/en/stable/, for web server code. I guess its time to start tinkering.
B
6
S
2
Posts: 24
Reputation: 699

Post » Tue Oct 01, 2013 6:25 pm

I have some issues with the WebSockets and multiplayer games section and have voiced my concern in another thread. It is wrong about TCP being a problem: completely wrong. I don't think "reliable transmission" means what they think it means, and their argument seems irrelevant to any reasonable kind of design. I'll go into detail if you wish, but you can also just look through the discussion here:
http://www.scirra.com/forum/topic75529.html

I think Node.js has been popular because it's JS. That's their big sales point. A lot of front-end developers have good JavaScript skills. That's why setting up for JavaScript handlers on the server-side is on my list. I started playing with that while working on the HLL Framework, and it's about time I finished it. But it's going to be running in a system written in Java, which is much faster.

I haven't done timing tests to answer your second question. When I run the demo on the same LAN as the server, it seems instantaneous. WebSockets have the most efficient message passing protocol possible, other than just passing raw data and nothing else (simple socket server). From there, delay is greatly overshadowed by Internet speeds which can be unpredictable (no matter whether you're using TCP or something else by the way).

I'd like to ask a question back. For you, what seems to be the difference between 50 and 100 ms? I mean to the game design you have in mind?

Before trying to answer your last question, I must confess that I know nothing about Tornado. It says that it's a framework that they consider ideal for "applications like" websockets among other things. The reason they give is that it can "can scale to tens of thousands of open connections". So can any good server. So, not being familiar with it, I can's say why I'd use it.

But in any case, I think your point is that you think Tornado is something you can figure out. It's really my goal to provide the framework (based on HLL Framework) around the HLL WebSocket server that will be easy for a lot of people to use.
B
6
S
1
Posts: 76
Reputation: 606

Post » Wed Oct 02, 2013 1:12 am

[QUOTE=rogerfgay]
I'd like to ask a question back. For you, what seems to be the difference between 50 and 100 ms? I mean to the game design you have in mind?
....
So can any good server [does what Tornado claims]. So, not being familiar with it, I can's say why I'd use it.
....
It's really my goal to provide the framework (based on HLL Framework) around the HLL WebSocket server that will be easy for a lot of people to use.
[/QUOTE]
I'd like to know what kind of time frame client and server can communicate. I guess if I'm constantly seeing less then 100 ms in most all domestic US stuff I can assume a WebSocket can do the same.


I'm only looking at Tornado because its written in Python. I don't know JavaScript. Although, I probably should learn it so I can make C2 plugins. Teaching myself and using either Oracle's Java or a C variant are not an option for me.


How are you trying to make it easy to use? It seems to me the problem is its not easy to setup the server. In order for the majority of C2 users to start using WebSockets we'd need a non-coding really simple way of setting up the server. I guess what C2 needs is a plug and play server where we upload a C2 exported html5/WebGl project that acts as the server. How about creating a Dropbox Application? With this users can drop their server C2 files there and easy-setup program takes over from there.


I'm now wondering if it would be possible to use C2 to make the server side program. I don't know how many concurrent connections a C2 created app can handle. Then there are all the logic decisions to handle 100's of different entities doing things, and finally the database is likely another issue. Perhaps a C2 plugin could be made to interface with SQLite.


My basic idea for a game uses a scheme where client and server send/receive dictionary of arrays in JSON format. It would be an isometric view adventure, hoarding, building game.
* the Clients job is to capture user input (keyboard, mouse click, I'm not sure how to do mouse stroke yet). Format it into and array, then asJson, and send to server. The client uses JSON data received from the server to draw the world relative to its view point. In other words making and sending serialized user input; and receiving view point relative drawing information.

* the Server stores all persistent data in a data base, does all logic, and sends what the clients needs to know to render its current view.
B
6
S
2
Posts: 24
Reputation: 699

Post » Wed Oct 02, 2013 6:45 am

@rogerfgay,

i will preface by saying i know nothing about server code.

is there a great deal of difference between coding 'turn-based' multiplayer, as opposed to real time or semi real time? i ask because i have seen a plethora of websocket/online/multiplayer type threads begin and end, in no short time. not because the people were not motivated, but because the task seemed to big to encompass. at this point, i don't think there is a way to accommodate everyone...unfortunately. so, would it be more plausible to create a 'simple' turn-based setup for multiplayer, that would work for all the game types that would require it. and then, later tackle the 'big' stuff.

as i said, i know nothing of the intricacies of this stuff. so i'm speaking from a position of extreme ignorance.

please forgive me.
B
81
S
32
G
23
Posts: 1,053
Reputation: 35,965

PreviousNext

Return to Work in Progress Addons

Who is online

Users browsing this forum: No registered users and 0 guests