Probably easy but Socket stream pub/sub not working for me #340

Closed
thebadger412 opened this Issue Jan 15, 2013 · 14 comments

Comments

Projects
None yet
3 participants

I am trying to follow the guide here

https://github.com/socketstream/socketstream/blob/master/doc/guide/en/pub_sub_events.md

but when I boot node and require socketstream

and I do

ss.publish. (press tab)

there are no such methods such as "channel" or "all" in publish so I don't know how to carry on with this guide..

Contributor

paulbjensen commented Jan 15, 2013

Yep, so there are 2 API methods exposed: 1 inside of rpc files, and another for all other files. You'll need to call ss.api.publish.

Here is the linked section in that document: https://github.com/socketstream/socketstream/blob/master/doc/guide/en/pub_sub_events.md#publishing-events-via-appjs

Lol hi again..

Okay I might be going crazy here but in api there is no publish..

Contributor

paulbjensen commented Jan 16, 2013

What file contains the call to ss.api.publish, and how is it being loaded (in a separate Node.js process to the SocketStream app, or as a require("./example_file") in the SocketStream app's codebase)?

I have created a file in /rpc called serial and in that just started playing with ss.api.publish

but it said no modules called publish..or it was undefined, so I started digging around

so then I just created a random directory on computer, installed SS

and then in node I can view all of ss's methods and when I look in publish or in api I cannot find anything we are talking about..

heres a gist

https://gist.github.com/4543612

Hopefully you can see where I am looking, it doesn't appear that the channel method is anywhere?

Contributor

paulbjensen commented Jan 16, 2013

The folder path needs to be server/rpc, then run node app.js.

Contributor

paulbjensen commented Jan 20, 2013

Hi, just wanted to ask if changing the path of the file from rpc/serial.js to server/rpc/serial.js did the trick?

Hey man, I can't get access to my computer with it on till monday,

However I am having another issue with dashku you might be able to shed
light on..

I have tried this on 2 comps now and same error, both ubuntu.. going to try
windows soon..

cloned your dashku repo,

got mongo running

got redis running.. started it,
When I click sign up though with my data input the server crashes with this
output..

Segmentation Fault (core dumped)
*
*
Just wondered if you have had this problem before?

Cheers

On 20 January 2013 00:42, Paul Jensen notifications@github.com wrote:

Hi, just wanted to ask if changing the path of the file from rpc/serial.js
to server/rpc/serial.js did the trick?


Reply to this email directly or view it on GitHubhttps://github.com/socketstream/socketstream/issues/340#issuecomment-12463954.

Contributor

paulbjensen commented Jan 20, 2013

Sorry, I'm in github-issues-driven development mode ;)

Luckily for you, I ran into this once. I believe it was to do with using npm modules being compiled against a older version of Node.js (0.8.12), then using a updated version of Node.js (0.8.16).

The suggestion here is to remove all modules in the app's node_modules folder ('rm -rf node_modules' works for me), then run 'npm install' again, then the app runs again.

owenb commented Jan 24, 2013

Hi @thebadger412

Please follow @paulbjensen's suggestion and let us know how you get on. If this is now working for you, please close the issue.

Okay hi, so I am sure I am doing this wrong, I am a total newb but really want to get it working if you could help me..

So I am using dashku and as @paulbjensen mentioned to me in an email, if I want to communicate with one of his widgets I would have to put the following code in /server/rpc/serial.js

ss = require('socketstream');
ss.api.publish.channel("user_<MONGODB_ID_FOR_YOUR_USER>", 'transmission', {_id: "YOUR_WIDGET_ID", randomDataAttribute: randomDataValue});

So I created the "bigNumber" widget and found out all the relevant id's

so I have cloned his git and the only thing I have added is that one file in /server/rpc..

here is the entire contents of my file

ss = require('socketstream');

ss.api.publish.channel("user_<51019b9b821cf8db0d000002>", 'transmission', {_id: "51019fe9357865660e000014", bigNumber: 212});

and when I run coffee app.coffee I get the following error

https://gist.github.com/4627704

Hopefully someone can just say.. oh no just add a semi colon and it all works wooo

Contributor

paulbjensen commented Jan 24, 2013

Hi @thebadger412,

Files inside of the server/rpc folder need to be structured with this code:

exports.actions = (req,res,ss) ->

    example: ->
        ss.api.publish.channel('channelName','eventName', {data:'value'});

Take a look at this file in Dashku for reference: https://github.com/Anephenix/dashku/blob/master/server/rpc/dashboard.coffee#L44

Also note that ss is being inherited from exports.actions (req,res,ss), not the require at the top of the file.

I really appreciate the help but try as I might this thing will not work..

Okay so just so we are clear, the only thing I have done is cloned the dashku git and then created the big number widget.. nothing else

I am then creating this file "server.coffee" in /server/rpc..
https://gist.github.com/4633233

as you can see it has a few trials in there by me, all of them failed with the same error as before..
I am thinking there is something else I must have to do to make this work.. like do I need to put some code in the widget or something? because at the minute I just don't know what to do..

Like I want it so as soon as the server starts it sends this value to bigNumber..

Contributor

paulbjensen commented Jan 25, 2013

Commented on the gist file.

Also, in relation to "Like I want it so as soon as the server starts it sends this value to bigNumber..", you'll need to make an RPC call somewhere (either from browser or terminal, or somewhere in the app.js file after the server is started and a port is listened on) - Here is the relevant document about RPC: https://github.com/socketstream/socketstream/blob/master/doc/guide/en/rpc_responder.md

owenb commented Mar 14, 2013

Hi there

Can you let me know where we are with this? Please close the issue if this is now working for you.

owenb closed this Apr 3, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment