[PLUGIN] Zack0Wack0's Construct 2 Plugins

Post your completed addons to share with the community

Post » Tue Sep 11, 2012 7:54 am

Hi!

First you have to SplitDataReceived to get some consistent LastDataElement.This plugin splits data where is a comma sign, eg.

If your message looks like 'message',"Some,data,here" it will be split like this:

Socket.LastDataElement(0)="Some"
Socket.LastDataElement(1)="data"
Socket.LastDataElement(2)="here"

As you can notice, Socket.LastDataElement requires an index number, starting from zero.

As for the error i cannot really tell you something useful, if you could post .capx and server code, it would be possible to pin-point the error more accurate.

Also, there is a few versions of that plugin on the forum (it's pretty unstable plugin, there is great community effort to make it more stable, hence a few versions of it exist), so if you could tell us where did you download Socket plugin, or share the plugin here!
Be nice until it's time to not be nice
B
36
S
9
G
9
Posts: 293
Reputation: 6,652

Post » Wed Sep 12, 2012 12:48 am

Hey Johnny,

Thanks for the great answer though unfortunately my game is still not receiving data properly until the non-specific Socket.LastData expression is used.

I'm using the socket.io version that was updated by Rexrainbow, and I'm following this guide/example of how to set up multiplayer: http://jptarqu.blogspot.com.au/2012/04/how-to-create-online-multiplayer-html5.html

I've followed exactly, the socket is receiving and seems to be writing messages just fine, so all i can figure is I'm doing something wrong with the Socket.LastDataElement(index).

I would post the file for downloading but I'm not sure how to do that:P Will gladly post it otherwise.

Currently my socket is writing
debug- websocket writing 5:::{"name":"M,10"}
debug- broadcasting packet

and I have construct 2 set up to receive like this:
Socket On Connect
Socket: Is data available? - socket: Split Data Received
System: Socket:LastDataElement(0) = M - System: Set M to Socket:LastDataElement(1)

Thanks again for any help:)
B
3
Posts: 4
Reputation: 658

Post » Wed Sep 12, 2012 12:51 pm

If you're using rexrainbows socket.io plugin, you should probably follow his instructions. I think he made a special plugin to communicate with his server, so i don't believe it will work with juantars demo. As i haven't read the source of rexrainbows socket.io plugin, i really cannot tell you how it works, so you could maybe ask him?

To set up juantars demo, you can use this mod or this mod of the plugin.

Both should do the work.
Be nice until it's time to not be nice
B
36
S
9
G
9
Posts: 293
Reputation: 6,652

Post » Mon Sep 17, 2012 12:40 am

@JohnnySheffield

Sure, the protocol of my plugin to send command/data is different with juantars's. And my server is different with juantars's.rexrainbow2012-09-17 03:17:38
B
97
S
22
G
178
Posts: 4,122
Reputation: 104,051

Post » Fri Jan 04, 2013 4:31 pm

Hello,

I have a external game server running on port 8000. Can I connect to that port and communicate with the server using socket.io plugin.

I have installed node.js and socket.io Then what shall I do next to do this?
B
2
Posts: 2
Reputation: 504

Post » Wed May 22, 2013 4:08 pm

github page not found????
B
1
Posts: 1
Reputation: 127

Post » Mon Jul 22, 2013 4:12 pm

I have spent days trying to get this plugin (and the official web socket plugin) working, but they do nothing.

I tried the echo test project, does nothing but create a blank page.

I.e. something is seriously not working.

Also, neither work at all with node.js.

I am running node.js with socket.io on port 8080, using this very simple app:

var io = require("socket.io").listen(8080);
io.sockets.on('connection', function (socket) {
    console.log("connected");
    socket.emit('balls', { ball:42 });
    socket.on('daub', function (data) {
      console.log(data);
    });
});

If I just write a dumb HTML page, it works perfectly:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
</head>
<body>
<script src="socket-io/socket.io.js"></script>
<script>
var socket = io.connect('http://localhost:8080');
socket.on('balls', function (data) {
    console.log(data);
    socket.emit('daub', { my: 'data' });
});
</script>
</body>
</html>

I get 42 logged in the console

I have tried various plugins, (there are lot of versions floating round), none of them work at all, no error, nothing in console, no error events, no events what so ever.

E.g. this 3 line socket.io plugin app doesn't do anything:



Nor does this one using the official plugin:



I am trying on the latest chrome and FF. Neither work. using the developerconsole/firebug, they show no socket connections being made. Ill try using wireshark, but the impression I get is that the "connect to" method is simply not making any connection attempt.

I have also tried exporting the projects as html5 sites, and running them from there. no joy.nutmix2013-07-22 16:18:21
B
15
S
5
G
2
Posts: 357
Reputation: 3,691

Post » Sun Aug 21, 2016 11:14 am

Hi,
I'm trying this but I cannot connect to the node server.
This is the server code:
Code: Select all
var io = require("socket.io").listen(8080);

io.sockets.on("connection", function (socket) {
   console.log("connected");
});

and this is the only event in my project:

Image

It simply does not connect.
From this html page:
Code: Select all
<script src="node_modules/socket.io/node_modules/socket.io-client/socket.io.js"></script> 
<script> 
    var socket = io.connect("http://localhost:8080");
</script> 

it connects.

Can someone help? Thank you!!!
B
10
S
3
Posts: 35
Reputation: 672

Previous

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 1 guest