Forums » Union Coders »
Executing heavy code on the server - ? best solution
Added by Kenneth Gilpin 633 days ago
Could I ask the forum for advice on a problem which may have a solution within this platform?
I'm currently using the union platform to provide ad hoc medical patient simulation. We are getting a huge amount of international interest!
Physiological modelling is really limited by the clients' computing power, and we are assuming the lowest common denominator as our design brief should be that it can run in developing countries (on old computers). In order to improve model fidelity I want to move some of the processor intensive (but not time critical) algorithms onto the server. I.e. simply send the data to a server side function, and use the returned value.
Is this possible within the Union framework? If so what language would I need to write it in? We have people on our team who can program in Java, ECMAscript derivatives, and C/C+, as well as the usual server side scripts.
If not could I ask the forum what solutions they would consider? It would be nice if the solution could be extendable to potentially very complex and processor intensive applications.
kenneth
ps great news about the license.
Replies
RE: Executing heavy code on the server - ? best solution - Added by colin moock 633 days ago
hi kenneth,
Union's room modules are designed precisely to suit your needs. Modules can be written in Java or JavaScript, or many other supported scripting languages.
for complete information, please see:
http://www.unionplatform.com/?page_id=1072
We have a "fridge magnets" example that we will post very soon showing how to send a message to a room module and have the module respond. I think it demonstrates exactly what you are looking for. To tell the server to "move a magnet", the client sends the following module message:
var moduleArgs:Object = new Object();
moduleArgs.MAGNET = Magnet(e.target).name;
moduleArgs.X = Magnet(e.target).x;
moduleArgs.Y = Magnet(e.target).y;
room.sendModuleMessage("MOVE", moduleArgs);
the server receives the message as follows, and responds by setting a room attribute that is automatically shared with all room occupants.
public void onModuleMessage(RoomEvent evt) {
Message msg = evt.getMessage();
// --- if a move letter message then place the letter
if ("MOVE".equals(msg.getMessageName())) {
// --- get letter index and set the attribute
try {
int magnet = Integer.parseInt(msg.getArg("MAGNET").substring(6));
m_ctx.getRoom().setAttribute(msg.getArg("MAGNET"),
m_letterPool[magnet]+","+msg.getArg("X")+","+msg.getArg("Y"),
Attribute.SCOPE_GLOBAL, Attribute.FLAG_SHARED | Attribute.FLAG_SERVER_ONLY);
} catch (NumberFormatException e) {
e.printStackTrace();
} catch (AttributeException e) {
e.printStackTrace();
}
}
}
i'll try to get the full example up today or tomorrow.
colin
RE: Executing heavy code on the server - ? best solution - Added by Kenneth Gilpin 627 days ago
I'm just reviewing the fridge magnets application now. So many potential uses...
When I'm testing applications for this how would I put Java classes on the server? Can you just upload them to the union server?
My fear is that debugging this could be difficult.
kenneth
RE: Executing heavy code on the server - ? best solution - Added by colin moock 627 days ago
ya, server-side modules are very powerful. in the end, nearly all complex applications that are not on a closed network involve some server-side programming.
to use server-side modules, you must run your own copy of union server. we do not allow people to upload custom modules to tryunion.com. our normal workflow is to run union server on the machine being used for client development. the testing and debugging cycle is pretty quick when everything is on the same machine.
colin