Commit a726bcaa authored by Constantin Jucovschi's avatar Constantin Jucovschi

updating client js

parent 205b9b67
This diff is collapsed.
......@@ -6,10 +6,6 @@ var _info_kwarc_sally_comm_core_factory = function () {
type: 'classInfo',
localName: 'HeartbeatResponse',
propertyInfos: []
}, {
type: 'classInfo',
localName: 'HeartbeatRequest',
propertyInfos: []
}, {
type: 'classInfo',
localName: 'RegisterClientResponse',
......@@ -39,19 +35,23 @@ var _info_kwarc_sally_comm_core_factory = function () {
elementName: 'EnvironmentID',
typeInfo: 'String'
}]
}, {
type: 'classInfo',
localName: 'HeartbeatRequest',
propertyInfos: []
}],
elementInfos: [{
elementName: 'HeartbeatResponse',
typeInfo: 'info_kwarc_sally_comm_core.HeartbeatResponse'
}, {
elementName: 'HeartbeatRequest',
typeInfo: 'info_kwarc_sally_comm_core.HeartbeatRequest'
}, {
elementName: 'RegisterClientResponse',
typeInfo: 'info_kwarc_sally_comm_core.RegisterClientResponse'
}, {
elementName: 'RegisterClientRequest',
typeInfo: 'info_kwarc_sally_comm_core.RegisterClientRequest'
}, {
elementName: 'HeartbeatRequest',
typeInfo: 'info_kwarc_sally_comm_core.HeartbeatRequest'
}]
};
return {
......
......@@ -4,22 +4,74 @@ var _info_kwarc_sally_comm_frames_factory = function () {
defaultElementNamespaceURI: 'http:\/\/kwarc.info\/sally\/comm\/frames',
typeInfos: [{
type: 'classInfo',
localName: 'RemoveDocLevelService',
localName: 'ExecuteFrameRequest',
propertyInfos: [{
type: 'element',
name: 'id',
elementName: 'id',
name: 'frameid',
elementName: 'frameid',
typeInfo: 'String'
}]
}, {
type: 'classInfo',
localName: 'ExecDocLevelService',
localName: 'ShowSallyFrameMenu',
propertyInfos: [{
type: 'element',
name: 'id',
elementName: 'id',
name: 'posx',
elementName: 'posx',
typeInfo: 'Int'
}, {
type: 'element',
name: 'posy',
elementName: 'posy',
typeInfo: 'Int'
}]
}, {
type: 'classInfo',
localName: 'GetSallyFramesResponse',
propertyInfos: [{
type: 'element',
name: 'sallyFrameMenuItem',
collection: true,
elementName: 'SallyFrameMenuItem',
typeInfo: 'info_kwarc_sally_comm_frames.GetSallyFramesResponse.SallyFrameMenuItem'
}]
}, {
type: 'classInfo',
localName: 'GetSallyFramesResponse.SallyFrameMenuItem',
propertyInfos: [{
type: 'element',
name: 'itemid',
elementName: 'itemid',
typeInfo: 'String'
}, {
type: 'element',
name: 'frame',
elementName: 'frame',
typeInfo: 'String'
}, {
type: 'element',
name: 'name',
elementName: 'name',
typeInfo: 'String'
}]
}, {
type: 'classInfo',
localName: 'GetSallyFramesRequest',
propertyInfos: [{
type: 'element',
name: 'posx',
elementName: 'posx',
typeInfo: 'Int'
}, {
type: 'element',
name: 'posy',
elementName: 'posy',
typeInfo: 'Int'
}]
}, {
type: 'classInfo',
localName: 'ListenDocLevelServices',
propertyInfos: []
}, {
type: 'classInfo',
localName: 'NewDocLevelService',
......@@ -46,38 +98,47 @@ var _info_kwarc_sally_comm_frames_factory = function () {
}]
}, {
type: 'classInfo',
localName: 'ListenDocLevelServices',
propertyInfos: []
localName: 'RemoveDocLevelService',
propertyInfos: [{
type: 'element',
name: 'id',
elementName: 'id',
typeInfo: 'String'
}]
}, {
type: 'classInfo',
localName: 'ShowSallyFrameMenu',
localName: 'ExecDocLevelService',
propertyInfos: [{
type: 'element',
name: 'posx',
elementName: 'posx',
typeInfo: 'Int'
}, {
type: 'element',
name: 'posy',
elementName: 'posy',
typeInfo: 'Int'
name: 'id',
elementName: 'id',
typeInfo: 'String'
}]
}],
elementInfos: [{
elementName: 'RemoveDocLevelService',
typeInfo: 'info_kwarc_sally_comm_frames.RemoveDocLevelService'
elementName: 'ExecuteFrameRequest',
typeInfo: 'info_kwarc_sally_comm_frames.ExecuteFrameRequest'
}, {
elementName: 'ExecDocLevelService',
typeInfo: 'info_kwarc_sally_comm_frames.ExecDocLevelService'
elementName: 'ShowSallyFrameMenu',
typeInfo: 'info_kwarc_sally_comm_frames.ShowSallyFrameMenu'
}, {
elementName: 'NewDocLevelService',
typeInfo: 'info_kwarc_sally_comm_frames.NewDocLevelService'
elementName: 'GetSallyFramesResponse',
typeInfo: 'info_kwarc_sally_comm_frames.GetSallyFramesResponse'
}, {
elementName: 'GetSallyFramesRequest',
typeInfo: 'info_kwarc_sally_comm_frames.GetSallyFramesRequest'
}, {
elementName: 'ListenDocLevelServices',
typeInfo: 'info_kwarc_sally_comm_frames.ListenDocLevelServices'
}, {
elementName: 'ShowSallyFrameMenu',
typeInfo: 'info_kwarc_sally_comm_frames.ShowSallyFrameMenu'
elementName: 'NewDocLevelService',
typeInfo: 'info_kwarc_sally_comm_frames.NewDocLevelService'
}, {
elementName: 'RemoveDocLevelService',
typeInfo: 'info_kwarc_sally_comm_frames.RemoveDocLevelService'
}, {
elementName: 'ExecDocLevelService',
typeInfo: 'info_kwarc_sally_comm_frames.ExecDocLevelService'
}]
};
return {
......
......@@ -3,6 +3,24 @@ var _info_kwarc_sally_comm_theo_factory = function () {
name: 'info_kwarc_sally_comm_theo',
defaultElementNamespaceURI: 'http:\/\/kwarc.info\/sally\/comm\/theo',
typeInfos: [{
type: 'classInfo',
localName: 'CloseTheoWindow',
propertyInfos: [{
type: 'element',
name: 'id',
elementName: 'id',
typeInfo: 'String'
}]
}, {
type: 'classInfo',
localName: 'OpenTheoWindowResponse',
propertyInfos: [{
type: 'element',
name: 'id',
elementName: 'id',
typeInfo: 'String'
}]
}, {
type: 'classInfo',
localName: 'OpenTheoWindowRequest',
propertyInfos: [{
......@@ -36,34 +54,16 @@ var _info_kwarc_sally_comm_theo_factory = function () {
elementName: 'height',
typeInfo: 'Int'
}]
}, {
type: 'classInfo',
localName: 'CloseTheoWindow',
propertyInfos: [{
type: 'element',
name: 'id',
elementName: 'id',
typeInfo: 'String'
}]
}, {
type: 'classInfo',
localName: 'OpenTheoWindowResponse',
propertyInfos: [{
type: 'element',
name: 'id',
elementName: 'id',
typeInfo: 'String'
}]
}],
elementInfos: [{
elementName: 'OpenTheoWindowRequest',
typeInfo: 'info_kwarc_sally_comm_theo.OpenTheoWindowRequest'
}, {
elementName: 'CloseTheoWindow',
typeInfo: 'info_kwarc_sally_comm_theo.CloseTheoWindow'
}, {
elementName: 'OpenTheoWindowResponse',
typeInfo: 'info_kwarc_sally_comm_theo.OpenTheoWindowResponse'
}, {
elementName: 'OpenTheoWindowRequest',
typeInfo: 'info_kwarc_sally_comm_theo.OpenTheoWindowRequest'
}]
};
return {
......
<HTML>
<script type="text/javascript" src="/lib/require.js"></script>
<script type="text/javascript" src="/lib/underscore-min.js"></script>
<script type="text/javascript" src="/lib/jquery-ui/jquery.js"></script>
<script type="text/javascript" src="/lib/jquery-ui/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="/lib/jquery-ui/css/smoothness/jquery-ui.min.css">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.20/require.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.js"></script>
<script type="text/javascript">
require.config(
......@@ -30,11 +29,15 @@ require(["sally_client", "theo", "frames"], function(SallyClient, Theo, Frames)
console.log(msg);
});
client = new SallyClient({stompUrl: "ws://localhost:61614", stompUser : "webclient", stompPassword : "webclient"});
client = new SallyClient({stompUrl: "ws://localhost:61614", stompUser : "karaf", stompPassword : "karaf"});
client.register([theo, frames], "env"+Math.floor(Math.random()*100000), function() {
setTimeout(function() {
client.register([theo, frames], "env"+Math.floor(Math.random()*100000), function() {
});
}, 1500);
});
});
</script>
......
......@@ -19,6 +19,17 @@ define (require) ->
"posy" : y
}
createGetSallyFrames = (x, y) ->
{
name :
localPart : "GetSallyFramesRequest"
namespaceURI : "http://kwarc.info/sally/comm/frames"
value :
"posx" : x,
"posy" : y
}
listenDocLevelServices = () ->
{
name :
......@@ -53,6 +64,22 @@ define (require) ->
requestOnShowSallyFrames : (x, y) ->
@send(createShowSallyFrameMenu(x, y))
requestSallyFrames : (x, y, callback) ->
@send(createGetSallyFrames(x, y), (response) ->
callback(response.value.sallyFrameMenuItem);
)
executeSallyFrame : (itemid) ->
@send(
{
name :
localPart : "ExecuteFrameRequest"
namespaceURI : "http://kwarc.info/sally/comm/frames"
value :
frameid : itemid
})
handleMessage : (msg, sendBack) ->
if msg.name.localPart == "NewDocLevelService"
@services[msg.value.id] = msg.value;
......
......@@ -44,19 +44,17 @@ define (require) ->
@stompClient = Stomp.client(config.stompUrl)
connections[config.stompUrl] = @stompClient
@stompClient.connect(config.stompUser, config.stompPassword, ((frame) ->
@stompClient.connection_div.emit("onConnected");
@stompClient.connection_div?.emit("onConnected");
).bind(@))
register : (@schemas, envid, callback) ->
me = @;
client = @stompClient
if client.connected
return callback();
if not client.connection_div?
if not client.connection_div?
client.connection_div = new EventEmitter()
schemaMap = {};
@schemaMap = {};
for x in schemas
schemaMap[x.getName()] = x;
@schemaMap[x.getName()] = x;
client.connection_div.on("onConnected", (e) =>
@privateQueue = "editor_tools_"+Math.floor(Math.random()*100000);
......@@ -69,7 +67,7 @@ define (require) ->
@send(msg.headers["reply-to"], marshaller.marshalString(heartBeatResponse), null, {"correlation-id" : msg.headers["correlation-id"]})
return;
else
handler = schemaMap[namespace];
handler = @schemaMap[namespace];
body = handler.unmarshal(msg.body)
handler.handleMessage(body, (sendBack) =>
......@@ -90,12 +88,21 @@ define (require) ->
)
if client.connected
client.connection_div.emit("onConnected")
send : (destination, msg, callback, headers) ->
if callback?
corrid = Math.random();
queue_post = "/temp-queue/editor_exchange"+corrid;
sub = @stompClient.subscribe(queue_post, (msg) =>
body = unmarshaller.unmarshalString(msg.body)
sub = @stompClient.subscribe(queue_post, (msg) =>
namespace = xmlns.exec(msg.body)[3];
if namespace == "core"
body = unmarshaller.unmarshalString(msg.body)
else
handler = @schemaMap[namespace];
body = handler.unmarshal(msg.body)
if callback(body, msg) == true
return;
@stompClient.unsubscribe(corrid);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment