WebSockets: What do you want?

Post your work in progress addons and get feedback

Post » Sat Sep 07, 2013 2:12 pm

And I apparently need to install CSWebSocket_plugin.js ... searched the directories and then googled, but haven't found it.
B
6
S
1
Posts: 76
Reputation: 606

Post » Sat Sep 07, 2013 2:29 pm

You will need to set up the server info in event 1.
Thats just how it could be set up for the client side.
Your end will require a fair bit more.

Also that error notice should gone in the next release.

newt2013-09-07 14:31:35
Image ImageImage
B
168
S
50
G
164
Posts: 8,228
Reputation: 105,575

Post » Sat Sep 07, 2013 2:42 pm

That's weird. It began running in Chrome after I used the short-cut to display the html file source, but I can't inspect code. And although it's not actually running in Firefox, I'm now (after viewing source too) looking at the CSWebsocket code in Firebug.

OK ... So, I should set up server info in event 1 ... but how to I trigger the dictionary update based on received info as you suggested. I'm used to editing directly in code and I'm not seeing any in the development system so far.

(also wish the forum would stop timing me out)
rogerfgay2013-09-07 14:43:28
B
6
S
1
Posts: 76
Reputation: 606

Post » Sat Sep 07, 2013 2:48 pm

I might be catching on ... I can set values for key right, etc. on the websocket. Will that prepare and send a message? Will it interpret and apply if it receives a message with the codes I set in the same form?
B
6
S
1
Posts: 76
Reputation: 606

Post » Sat Sep 07, 2013 3:19 pm

Just as a quick experiment, I entered the ws address for my demo. I can see the connection being made from localhost:5000, the C2 program, with some crazy Cookie data in it, referring to one of my blog articles. But then when I click right, left, or whatever, it requests /robots.txt, which causes it to drop the WebSocket connection. (My demo doesn't take kindly to special requests.)
B
6
S
1
Posts: 76
Reputation: 606

Post » Sat Sep 07, 2013 3:22 pm

I also read in a forum post that someone fixed a problem by setting protocol to something ... meaning yes, use it. Right now, it's set to null.
B
6
S
1
Posts: 76
Reputation: 606

Post » Sat Sep 07, 2013 3:54 pm

Firebug is telling me that it's continuously reloading localhost:5000
B
6
S
1
Posts: 76
Reputation: 606

Post » Sat Sep 07, 2013 9:34 pm

Not sure what that could be, but you might as well stop looking at the code from C2's side its just one big json interpreted by the engine.
C2 has a built in debugger, its actually a lot like Firebug, or Chromes.

Eventing also can be a bit hard to get the hang of at first.
You have to remember the events run in order top down every tick.

The capx I made just shows how to deal with the server so that the server doesn't have to send every tick, just when something changes.

Sending back to the server is a different story, its a little more complicated.

Right now your options are to monitor the key presses, and send that when something changes, or monitor the objects x,y, speed, angle, etc and send that data... when something changes. Obviously the former being less exact.

Or another option is to change the the movement, and set up a timer.
Something like on this Boolean start a timer, while the timer is running move until the timer is over, and when it ends reset the Boolean.

And yes the forum time out is a pain.
Image ImageImage
B
168
S
50
G
164
Posts: 8,228
Reputation: 105,575

Post » Sun Sep 08, 2013 7:35 am

Are you sure that the free version has a debugger? After my first day, which is a little hazy, I have to go back again and let things settle in. I now feel slightly more oriented, as though the day of understanding will in fact one day come. But I think I tried to click on some debugging stuff yesterday and found that it wasn't supported in the free version.

I don't need anything too fancy just to do this experiment / proof of concept thing. If I can get it to send a clear message that I pressed the right arrow (or JSON action description that goes with it or whatever), I can just maybe reverse it ... send back left arrow command; or something like that.

Was thinking about this yesterday ... the very first experiment doesn't even require two players. If I do the above, pressing right moves the sprite right, followed by returning to its original position in response to the reverse echo ... or ... maybe right + up or something, since if right + left happens too fast, it could look like nothing happened.

That would be very, very simple to do as long as the action sends a message to the server that I can modify and send back, and when received, the demo will carry out the new action.rogerfgay2013-09-08 07:36:18
B
6
S
1
Posts: 76
Reputation: 606

Post » Sun Sep 08, 2013 8:06 am

OK, the fog has started to clear a bit perhaps. I added a websocket action to each of the key events; sending a simple text message "right" "left" "up" and "down" to the server. Problem is, that there is a loop. When I start running it, it connects to the server and then sends text messages "right" "left" "up" and "down" over and over ad infinitum, even though I haven't pressed any of the keys.

So far, I'm just doing this with my demo server app ... which is nothing more than a simple echo server. So, the server does send back "right" "left" "up" and "down" in response to receiving those ... it just echos back what it receives. There is an exception. At first, I separately send back some text commenting on the WebSocket server, but I don't think there's any way for the app to respond to any of that ... it would just be uninterpretable text input to the app.

There may be no way for me to do this without studying the documentation and really understanding it all better. rogerfgay2013-09-08 08:10:59
B
6
S
1
Posts: 76
Reputation: 606

PreviousNext

Return to Work in Progress Addons

Who is online

Users browsing this forum: No registered users and 0 guests