JSONless actionHero: how should I tackle this?

50 views
Skip to first unread message

Rin Chan

unread,
Jan 8, 2014, 10:17:47 AM1/8/14
to action...@googlegroups.com
Hi everyone,

It's been almost a year since I last touched actionHero and the amount of progress that's been made has been amazing.  Thank you Evan and the contributors for keeping it going.  The amount of changes since 4.0.6 (the last time I used it) has just been incredible!

I've been trying to use actionHero as a pure telnet server.  This is fine because actionHero supports socket servers. Unfortunately, the responses I need from actionHero needs to be sent back to the client not as a JSON thing but as RAW.  On top of that, I might have to implement telnet protocol (fun times!)  This is all fine.  But I notice that actionHero has JSON messages hard coded from many different places. 

This is still okay. I simply added a relay function that converted the JSON message into the thing I want to send back and it's been working well.  But the problem I run into is when say, the welcome message has message.welcome and error messages are in message.error while the other messages are in message.data, which sometimes is an object. Is there some sort of standard to the JSON messages?  Is this something I should implement myself?

And also a noob question: is it better to extend (and replace) things from the actionHero files or edit them directly?

Thanks for your time.

Evan Tahler

unread,
Jan 8, 2014, 12:28:46 PM1/8/14
to Rin Chan, action...@googlegroups.com
Welcome back!  I think you are the first person on this mailing list (other than me) to use the socket server, so I'm glad someone else finds it useful :D

I think the way to approach this would be to add an option in `api.config.servers.socket` for "delimiter" or "format".  I'd like to stick with JSON inside actionHero, but we can add a formatter inside of `server.sendMessage` which could be passed a function which will used to format the output (if preset).  I'd like to keep JSON as the default, but this way you can write whatever custom output you need.  

Would you be OK writing a PR for this?

--
 Evan Tahler
 412.897.6361
 evant...@gmail.com



--
You received this message because you are subscribed to the Google Groups "actionHero.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to actionhero-j...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Rin Chan

unread,
Jan 8, 2014, 3:34:38 PM1/8/14
to action...@googlegroups.com, Rin Chan
That's a great idea! Much better than what I was thinking of.  Thanks!

You'll have to pardon my poor English ... what does it mean to write a PR? 

Evan Tahler

unread,
Jan 8, 2014, 3:35:07 PM1/8/14
to Rin Chan, action...@googlegroups.com
PR = Github Pull Request! 

--
 Evan Tahler
 412.897.6361
 evant...@gmail.com



Rin Chan

unread,
Jan 8, 2014, 4:34:22 PM1/8/14
to action...@googlegroups.com, Rin Chan
Oh!  Yes, that is totally doable. I will do my best.  I would have had to code it on my own anyways. :) 

brain...@gmail.com

unread,
Jan 15, 2014, 4:17:30 AM1/15/14
to action...@googlegroups.com, Rin Chan
I think this would be a great general feature for actionHero.

I am also struggeling with the fact that AH forces an output format. Even though I am a big fan of json, i dont think its always the best to use.

Reply all
Reply to author
Forward
0 new messages