on 06-02-2015 9:25 AM
Hi!
I am new at Design Studio and sdk developement. Right know i am trying to create a data source to connect to a websocket with socket.io. Server is running on a node.js. The server is receiving data. With the data source sdk i am trying to open a client an connect to the socket.
As mentioned i am still at the beginning. Right know i a struggling with the following aspects:
At the end i want to receive streaming data from the websocket and Display it in DS (i know, there's SAP ESP for that, but i would like to do it without it).
Thanks a lot and best regards!
Saood Alvi
Hi saood,
First of all nice experiement, which i too also want to do it for long time. If you want to include external javascript file. you can do it by including it in contribution.xml with <jsinclude>Your script</jsinclude>.
And i think you can't debug the javascript in eclipse so easily, browser is the best way to do it.
Thanks,
nithyanandam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nithyanandam!
Thanks for the fast reply!
I tried including the file through
<jsInclude>https://cdn.socket.io/socket.io-1.3.5.js</jsInclude>,
<jsInclude>http://192.168.159.128:34000/socket.io/socket.io.js</jsInclude> (since this the location of the server), as well as directly through a root path. Nothing seems to work.
I also checked if the file is being loaded from cdn (f12 --> Network tab). everything seems fine. but still no change. the file is loaded before the component.js
i was wondering if there is something wrong with the js code. maybe i am not initializing correctly?
var socket = io(config.SocketConn);
socket.on('message', function(msg) {
config.SocketConn = "http://192.168.159.128:34000";
console.log(msg);
});
br
saood
Hi Nithyanandam,
sry. Didn`t know. If needed I'll open a new thread.
Console output:
2015-06-02 13:33:59 [int.do] A JavaScript error occurred. io is not defined ReferenceError: io is not defined at null.<anonymous> (http://localhost:53790/aad/zen/mimes/sdk_include/com.mhp.jsondatasource/res/js/component.js?version=...) at new h (http://localhost:53790/aad/zen.rt.components.sdk/resources/js/sdk_handler-min.js?version=14332448157...) at sap.ui.core.Control.extend.storeProperties (http://localhost:53790/aad/zen.rt.components.sdk/resources/js/sdk_handler-min.js?version=14332448157...) at create (http://localhost:53790/aad/zen.rt.components.sdk/resources/js/sdkdatasource_handler-min.js?version=1...) at createAndAdd (http://localhost:53790/aad/zen/mimes/combined_static_includes_1.js?version=1433244815728:3515:50) at createControl (http://localhost:53790/aad/zen/mimes/combined_static_includes_1.js?version=1433244815728:3127:16) at dispatchCreateControl (http://localhost:53790/aad/zen/mimes/combined_static_includes_1.js?version=1433244815728:3098:15) at updateChildren (http://localhost:53790/aad/zen/mimes/combined_static_includes_1.js?version=1433244815728:3535:21) at init (http://localhost:53790/aad/zen/mimes/combined_static_includes_1.js?version=1433244815728:3694:21) at createAndAdd (http://localhost:53790/aad/zen/mimes/combined_static_includes_1.js?version=1433244815728:3704:1) -
u @ sap-ui-core.js:80
error @ sap-ui-core.js:80
sapbi_phx @ combined_static_includes_1.js?version=1433244815728:2213
sapbi_onBodyLoad @ int.do:52
sapbi_PageClass.initialize @ combined_static_includes_1.js?version=1433244815728:1333
sapbi_PageClass.initializePage @ combined_static_includes_1.js?version=1433244815728:1328
onload @ int.do:55
Br
Saood
I am not a fan of calling external servers for included JS files, actually sdk defines that all files should be included in the bundle you want to deliver. but anyway this is not the root cause of your issue.
is it quite possible, that you need to use the require statement to include this files as a simple include will not work.
Hi Karol!
Thanks a lot! I did have to use the require statement! I am getting my data know!
this is what i added in the component.js (for further use):
require.config({
paths: {
socketio: 'http://192.168.159.128:34000/socket.io/socket.io'
}
});
require(['socketio'], function(io) {
var socket = io.connect('http://192.168.159.128:34000');
console.log('socket connected');
socket.on('message', function(data) {
console.log(data);
});
});
however i do get an "socket is undefined" error but i think, like Nithyanandam suggested, it has something to do with the load sequence and the files are somehow reloaded.
thanks again and best regards,
saood
p.s.:i'll edit this post if there is something important to add
I wouldn't mess with the require context directly like that. Could you try this instead:
var myRequire = require.config({
paths: {
socketio: 'http://192.168.159.128:34000/socket.io/socket.io'
}
});
myRequire(['socketio'], function(io) {
var socket = io.connect('http://192.168.159.128:34000');
console.log('socket connected');
socket.on('message', function(data) {
console.log(data);
});
});
Hi Saood,
1. this topic should be actually covered by the SDK guide at http://help.sap.com/boad. Have you seen the description of contribution.xml? The short answer is, depends if you need to load it by requrie or can include this library directly. if directly, simple include in contribution.xml should help.
2. yes, you can - but this requires some real debug - eg. MS Visual Studio, then you can connect to the eclipse process and debug also in eclipse. For the most cases, debugging during execution in browser is easier to achieve.
Karol
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.