最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Two way communication with server side objects for web-application development - Stack Overflow

programmeradmin3浏览0评论

Background

My background is high scale object oriented middleware and Applications development for embedded devices and desktops with C++. Now we need to create a high scale web-app for our startup.


Question

Request-response based and continuous polling based current web-development frameworks looks very primitive, inefficient.

I am looking for pletely server-side object oriented and event based programming. Here is an example it,

There is a persistent object named employeeManager on server,

methods of this object,

empList getAllEmployeeList();  
empList getEmployeeOfDepartment(string strDept);  
/*Some more */

events of this object

employeeAdded(empID);  
employeeEdited(empID);  
employeeRemoved(empID);  
/*Some more */

Now, client side javascript should be able to call the methods of this (server-side) object and should be able to receive events of this object. We can have results of the method call in asynchronous mode. Framework should also provide a way so that view ( or html-js page ) can register for required server side events.

Is there any frameworks which works on this methodology. Anything like this on top of socketIO? Any framework which provides a good two way RPC between client javascript and sever side objects?

Background

My background is high scale object oriented middleware and Applications development for embedded devices and desktops with C++. Now we need to create a high scale web-app for our startup.


Question

Request-response based and continuous polling based current web-development frameworks looks very primitive, inefficient.

I am looking for pletely server-side object oriented and event based programming. Here is an example it,

There is a persistent object named employeeManager on server,

methods of this object,

empList getAllEmployeeList();  
empList getEmployeeOfDepartment(string strDept);  
/*Some more */

events of this object

employeeAdded(empID);  
employeeEdited(empID);  
employeeRemoved(empID);  
/*Some more */

Now, client side javascript should be able to call the methods of this (server-side) object and should be able to receive events of this object. We can have results of the method call in asynchronous mode. Framework should also provide a way so that view ( or html-js page ) can register for required server side events.

Is there any frameworks which works on this methodology. Anything like this on top of socketIO? Any framework which provides a good two way RPC between client javascript and sever side objects?

Share Improve this question edited Mar 28, 2013 at 15:58 Mariusz Jamro 31.7k25 gold badges127 silver badges169 bronze badges asked Oct 26, 2012 at 9:16 SunnyShahSunnyShah 30.5k30 gold badges96 silver badges139 bronze badges 3
  • This might be easier to answer if you said what kind of server stack you are working with - for example github./SignalR/SignalR helps push server side events to JS clients (among others) in a .NET based stack. – Jude Fisher Commented Oct 26, 2012 at 9:29
  • @JcFx, Thanks a lot for your response. No please, I will go with either Java or Javascript for server programming. – SunnyShah Commented Oct 26, 2012 at 9:39
  • Half the fun is building that part of the system from scratch -- or maybe that's just me :) I'm afraid I don't know of any pre-built systems to do of what you ask, but am watching to see what people put forward - is a good question. +1 to xyu for stating what I would have started with. – Pebbl Commented Oct 26, 2012 at 9:41
Add a ment  | 

5 Answers 5

Reset to default 2 +100

Try the following bo:

Node + socket.io + Backbone.Model + a bit of imagination.

I think the missing piece is a model like structure that can be used on both server side and client side. The model needs to synchronize state between server and client.

Here is an article that I find very interesting, and maybe you can use the technique described?

The article:

http://blog.andyet./2011/feb/15/re-using-backbonejs-models-on-the-server-with-node/

NodeJS and sockets.io. These can help achieve the desired effect.

Meteor is a Node.js based framework that uses sock.js for websocket munication and MongoDB for a database which is oriented for horizontally scalable apps. Meteor will pretty much do all the heavy lifting for you when it es to client-server synchronization - you will not have to write any code for database syncing. The result is a minimal codebase with mainly your application's logic instead of the req/resp overhead. You can have a look at the examples here: http://meteor./examples/leaderboard

If you want cross-language RPC you might find Apache Thrift useful. I believe there's a Javascript client (but have never used it). You could build an RPC framework on top of Socket.IO as many others have pointed out, but it feels like painting a cat to look like a cow... i.e. fun, but not particular productive

I'm sure you have already, or have some legacy constraint, but in case you haven't I'd take a second to think about whether RPC is really the model you want to use. RPC leakily abstracts the existence of network latency, and as such bakes a few shaky assumptions into the foundations of your app. There's a fairly short and readable critique of RPC in general (by AST no less) that might be worth a read.

If you're familiar with C++, you may want to check out G-WAN. They have a great example using Comet (what you're looking for), and there are also Node.JS wrappers too.

G-WAN also allows for client-side applets written in whatever language you need too. So, for you, C++, might be just what you're looking for.

This is a very scalable web application server. From all the benchmarks I've seen, Node.JS doesn't scale well with high-concurrency (I may be wrong on this, if I am, please let me know, and provide me with the information). That being said, I've done things very similarly to what you're talking about doing. All I had to do was write a very simple wrapper to translate from JS to whatever language it was that I was using at the time (for me I've done it with PHP, MivaScript, SMT and C).

But the key (for me) was using Comet, to cut down on unnecessary polling of the server.

发布评论

评论列表(0)

  1. 暂无评论