Comments (7)
Could you paste the full code of your plugin (first to last line)?
Thanks.
On Mar 20, 2015, at 9:52 AM, alessioguglielmo [email protected] wrote:
I wrote a plugin (and put it in ~/.c9/plugin/plugin-name) with following code:
var WebSocket = require('ws')
, ws = new WebSocket('ws://mylocalipaddress:8090/');
ws.on('open', function() {
ws.send('something');
});
ws.on('message', function(message) {
console.log('received: %s', message);
});
On localhost I have a server listening on port 8090var WebSocketServer = require('ws').Server
, wss = new WebSocketServer({port: 8090});
wss.on('connection', function(ws) {
ws.on('message', function(message) {
console.log('received: %s', message);
});
ws.send('something');
});
When I try to load the IDE athttp://localhost:8186/ide.html?sdk=1?debug=2
It loads only IDE but not the plugin and my server doesn't receive any data.
If I try the same code in a client loaded in a different container it works perfectly.
Thanks
—
Reply to this email directly or view it on GitHub #41.
from core.
define(function(require, exports, module) {
main.consumes = [
"Plugin", "commands", "ui", "util", "Dialog", "dialog.alert", "tabManager"
];
main.provides = ["example1"];
return main;
function main(options, imports, register) {
var Plugin = imports.Plugin;
var commands = imports.commands;
var ui = imports.ui;
var util = imports.util;
/***** Initialization *****/
var plugin = new Plugin("Ajax.org", main.consumes);
var emit = plugin.getEmitter();
var api = plugin.setAPIKey(options.apikey);
var loaded = false;
function load() {
if (loaded) return false;
loaded = true;
var WebSocket = require('ws')
, ws = new WebSocket('ws://172.17.2.119:8090/');
WebSocket.on('open', function() {
WebSocket.send('something');
});
WebSocket.on('message', function(message) {
console.log('received: %s', message);
});
// Test use of the API
// api.setPersistentData("user", { example: 123 }, function(err){
// api.getPersistentData("user", function(err, data){
// console.error(data.example === 123);
// });
// });
// Test loading relative content
console.error(require("text!./test.html"));
// Test dependencies
console.error(commands, options.color);
}
/***** Methods *****/
/***** Lifecycle *****/
plugin.on("load", function() {
load();
});
plugin.on("enable", function() {
});
plugin.on("disable", function() {
});
plugin.on("unload", function() {
loaded = false;
});
/***** Register and define API *****/
/**
*
**/
plugin.freezePublicAPI({
_events: [
/**
* @event draw
*/
"draw"
]
});
register("", {
example1: plugin
});
}
});
from core.
The plugin looks good, although I don't fully understand why you set an outside IP address in your plugin.
It loads only IDE but not the plugin and my server doesn't receive any data.
How do you know the plugin isn't loaded? Could you test by setting a console.log in your load() function?
If you check the network tab of the browser's console. Do you see the websocket trying to connect?
from core.
I have c9 on a container and a WebSocket server in a different docker
container. I suppose that plugin isn't loaded because in firebug I can't
find trace about console.log (when I added it) and also alert messages
aren't displayed at all. Likely it found some error and blocks js
execution... I will try to re-implement the scenario and check the network
tab.
2015-03-21 19:53 GMT+01:00 Ruben Daniels [email protected]:
The plugin looks good, although I don't fully understand why you set an
outside IP address in your plugin.It loads only IDE but not the plugin and my server doesn't receive any
data.
How do you know the plugin isn't loaded? Could you test by setting a
console.log in your load() function?If you check the network tab of the browser's console. Do you see the
websocket trying to connect?—
Reply to this email directly or view it on GitHub
#41 (comment).
from core.
Nope. In the network tab my websocket is absent...
from core.
I've checked package.json file. Should I add something to it?
{
"name": "c9.ide.example",
"description": "Cloud9 Custom Example Plugin",
"version": "1.12.16",
"author": "Ajax.org B.V. <[email protected]>",
"contributors": [
{
"name": "Ruben Daniels",
"email": "[email protected]"
}
],
"repository": {
"type": "git",
"url": "http://github.com/javruben/example.git"
},
"plugins": {
"example": {}
},
"categories": [
"example"
],
"licenses": []
}
I tried to use other "common node.js API" such as path or querystring (that have slightly different sintax) that I've seen in the documentation and they work perfectly. The problem is with "ws"
from core.
Worked around the problem using different way, passing data through fs, although the original problem I have quoted persists.
from core.
Related Issues (20)
- Self hosted --collab share error
- Failed to install SDK in Mac OS 10.14.3 HOT 1
- Error creating TMUX session: Cannot read property 'on' of undefined HOT 3
- hide toolbar
- Full Java support?
- Is this project dead? HOT 9
- no more update? HOT 2
- Vulnerabilities
- Can i integrate cloud9 ace editor separately
- Fresh install - git extension not working
- List of flags HOT 2
- Connect to the IDE from a subdomain? HOT 2
- Require password to access Theia in browser?
- connect to SSH workspace from self hosted c9 SDK
- Error: Cannot find module 'c9/urls'
- Python 2 out of support. HOT 1
- Failed to write to 'state.settings'. options.stream must be readable. HOT 8
- How to delete cloud9?
- C9 Sudden stop,
- download and parse revision history
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from core.