Skip to content
Snippets Groups Projects
Commit a726bcaa authored by Constantin Jucovschi's avatar Constantin Jucovschi
Browse files

updating client js

parent 205b9b67
No related branches found
No related tags found
No related merge requests found
/*!
* EventEmitter v4.2.7 - git.io/ee
* Oliver Caldwell
* MIT license
* EventEmitter v4.2.11 - git.io/ee
* Unlicense - http://unlicense.org/
* Oliver Caldwell - http://oli.me.uk/
* @preserve
*/
(function () {
;(function () {
'use strict';
/**
......@@ -22,7 +22,7 @@
var originalGlobalValue = exports.EventEmitter;
/**
* Finds the index of the listener for the event in it's storage array.
* Finds the index of the listener for the event in its storage array.
*
* @param {Function[]} listeners Array of listeners to search through.
* @param {Function} listener Method to look for.
......@@ -153,7 +153,7 @@
/**
* Semi-alias of addListener. It will add a listener that will be
* automatically removed after it's first execution.
* automatically removed after its first execution.
*
* @param {String|RegExp} evt Name of the event to attach the listener to.
* @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
......@@ -275,7 +275,7 @@
var single = remove ? this.removeListener : this.addListener;
var multiple = remove ? this.removeListeners : this.addListeners;
// If evt is an object then pass each of it's properties to this method
// If evt is an object then pass each of its properties to this method
if (typeof evt === 'object' && !(evt instanceof RegExp)) {
for (i in evt) {
if (evt.hasOwnProperty(i) && (value = evt[i])) {
......@@ -467,6 +467,6 @@
module.exports = EventEmitter;
}
else {
this.EventEmitter = EventEmitter;
exports.EventEmitter = EventEmitter;
}
}.call(this));
......@@ -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: []
}, {
type: 'classInfo',
localName: 'ShowSallyFrameMenu',
localName: 'RemoveDocLevelService',
propertyInfos: [{
type: 'element',
name: 'posx',
elementName: 'posx',
typeInfo: 'Int'
name: 'id',
elementName: 'id',
typeInfo: 'String'
}]
}, {
type: 'classInfo',
localName: 'ExecDocLevelService',
propertyInfos: [{
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,12 +29,16 @@ 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"});
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?
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) =>
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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment