Mongoose websocket won't run - sockets

I'm following Mongoose webserver on Github (https://github.com/cesanta/mongoose) and I want to test the websocket sample code.
Here are the codes that I copied:
Unfortunately when I run the code, it returns the following errors:
websocket.obj : error LNK2001: unresolved external symbol _find_embedded_file
C:\ProjectFolder\WebsocketDemo.exe : fatal error LNK1120: 1 unresolved externals
Did I miss something?

The makefile of the examples explain what is missing
There is a rule that generate websocket_html.c that embeded the websocket.html inside a c file (it defines the missing find_embedded_file function).
websocket_html.c: websocket.html
perl mkdata.pl $< > $#
If you prefer to give access to the websocket.html file, this could be done modifying the websocket.c sample
Setting the document_root option
mg_set_option(server, "document_root", ".");
Not handle the html url in the user handler
static int send_reply(struct mg_connection *conn) {
if (conn->is_websocket) {
...
} else {
return MG_FALSE; // mongoose will open file specified by the url
}
}

Related

How to add Babel support for nullishCoalescingOperator to vue project?

In my Vue-CLI project, when I tried using the ?? operator, I got this error:
Syntax Error: SyntaxError: /Users/stevebennett/odev/freelancing/v-map/src/components/Map.vue: >Support for the experimental syntax 'nullishCoalescingOperator' isn't currently enabled (30:29):
...
Add #babel/plugin-proposal-nullish-coalescing-operator (https://git.io/vb4Se) to the 'plugins' section of your Babel config to enable transformation.
I installed #babel/plugin-syntax-nullish-coalescing-operator (its name seems to have changed), added it to my babel.config.js:
module.exports = {
presets: ['#vue/app'],
plugins: ['#babel/plugin-syntax-nullish-coalescing-operator'],
};
Now the error message seems to have gone backwards, no reference to the operator name at all:
Module parse failed: Unexpected token (39:35)
You may need an appropriate loader to handle this file type.
| case 8:
| points = _context.sent;
console.log(sheetID ?? 37);
What am I doing wrong?
For me, the #babel/plugin-syntax-nullish-coalescing-operator plugin would not work, which is the one you are using.
I had to use the #babel/plugin-proposal-nullish-coalescing-operator plugin which is the one that the error message suggests you use.
Additionally, I noticed this on the page for the #babel/plugin-syntax-nullish-coalescing-operator plugin:
I can't say for sure if this will fix your problem, but it certainly fixed mine

T24 routine - compilation error - No component defined. $PACKAGE is mandatory?

Below is the sample code
SUBROUTINE HELLO.WORLD
*-----------------------------------------------------------------------------
*
*-----------------------------------------------------------------------------
* Modification History :
*-----------------------------------------------------------------------------
*-----------------------------------------------------------------------------
CRT "HELLO WORLD"
END
Compilation error;
01/01/2019 16:26:03 Compiling HELLO.WORLD... ERROR
Error : (line 12) HELLO.WORLD.b, No component defined. $PACKAGE is mandatory !
Compilation completed for 1 file(s). 1 error
01/01/2019 16:26:03 Compiling HELLO.WORLD... ERROR
Error : (line 12) HELLO.WORLD.b, No component defined. $PACKAGE is mandatory !
Compilation completed for 1 file(s). 1 error
I have setup (during toggle tafj project nature option in design studio);
The TAFJ_HOME correctly.
T24lib directory under "Known Libraries" section.
Java folder : ....\ProjectName-models\java.
Class folder : ....\ProjectName-models\classes.
Thank you
To switch off this check for tCompile, set these properties in tafj.properties:
temn.tafj.compiler.internal.development=false
temn.tafj.compiler.component.strict.mode=false
However, to follow the "best practice way" you should have the $PACKAGE statement, then your JBC code will be compiled into a proper Java Package and put inside a JAR file. Note that before that you should do "New-->T24Component Folder Structure" in T24 Design Studio. This will create the XX.componentname.component file where you can define the subroutines. This "XX.Local.component" has to be compiled first:
component XX.Local
# Component Isolation Definition
metamodelVersion 1.6
# -------------------------------------------------
public method helloWorld ()
{
jBC: HELLO.WORLD
}
Then you can reference the $PACKAGE in the subroutine like this:
$PACKAGE XX.Local
SUBROUTINE HELLO.WORLD
CRT 'Hello, World!'
RETURN
END
The component can also be created manually without Design Studio. You should not use the Dunce Cap (see this: https://en.wikipedia.org/wiki/Dunce) unless you have a good reason.
For R19 Right Click on project navigate to Properties->TAFJ->Compiler->Uncheck Maintain validation code.
Right click on project source folder and click “Put on / Take off the Dunce cap”. Compile again.
It's a subroutine , it needs a RETURN statement

vapor can not load html and leaf

I use vapor load a html or leaf,it gives me error message '500'.The server log show me
[Data File Error: unable to load file at path /Users/apple/Desktop/QSSwiftServer/Resources/Views/welcome.leaf]
[Identifier: Core.DataFileError.load]
[Possible Causes: file doesn't exist, missing read permissions at specified path, data read is corrupted, system issue]
[Suggested Fixes: ensure that file permissions are correct for specified paths]
[Documentation Links: https://developer.apple.com/reference/foundation/filemanager]
Here is my code:
get { req in
return try self.view.make("welcome.leaf", ["message": "Hello world!"])
}
How can I solve this problem?
You should put your file into {Project Dir}/Resources/Views/
In your case welcome.leaf should be in /Users/apple/Desktop/QSSwiftServer/Resources/Views/

Error: Missing either an "out" or "dir" config value with r.js / grunt-requirejs

Below is my build configuration file: build.js
{
appDir: '../src',
baseUrl: 'libs',
paths: {
app: 'js'
},
dir: '../prod',
out:"../js/main-built.js",
fileExclusionRegExp: /.less$/,
optimize: "uglify2",
optimizeCss: "standard",
modules: [{
name: '../js/main'
}]
}
I am using "grunt-requirejs": "~0.4.2" as my build npm and Gruntfile requirejs configuration + r.js 2.1.16:
requirejs: {
std: {
options: grunt.file.read('config/build.js')
}
}
Whenever i am try to execute grunt requirejs it is throwing below error on my console:
Error: Error: Missing either an "out" or "dir" config value. If using "appDir" for a full project optimization, use "dir". If you want to optimize to one file, use "out".
at Function.build.createConfig (d:\app\node_modules\grunt-requirejs\node_modules\requirejs\bin\r.js:27717:19)
I want to consolidate some of the JS files like jquery and its plugins etc. into 1 file and i am using AMD pattern similar to project https://github.com/hegdeashwin/Protocore
Can you please help me out here and tell what i have missed in my configuration ?
Thanks & Regards
You're using grunt.file.read which reads a file and returns the file's content as a string.
Use grunt.file.readJSON instead.

using SoapClient,ArrayObject, ArrayIterator causes error in zend framework

I'm working on some helpful method in my entity.
private function setApi($api_address,$api_username,$api_password){
$this->api_address = $api_address;
$this->api_username = $api_username;
$this->api_password = $api_password;
$this->api_client = new SoapClient($api_address); // error
}
Warning: require(App/Entity/SoapClient.php): failed to open stream: No such file or directory in /zendboilerplate/library/Doctrine/Common/ClassLoader.php on line 148 Fatal error: require(): Failed opening required 'App/Entity/SoapClient.php' (include_path='/zendboilerplate/application/../library:/zendboilerplate/application/../library/Bisna/Application/Resource:/zendboilerplate/library:.:/usr/share/php:/usr/share/pear') in /zendboilerplate/library/Doctrine/Common/ClassLoader.php on line 148
It seems that zend looks for a class declaration (and it doesn't use included classes in php).
Identical error for each "new Class" declaration.
Using a my own class included in library everything is ok.
(Also tried with #new SoapClient() but no result).
I'm guessing this is namespace related. Try changing the line that is erroring to:
$this->api_client = new \SoapClient($api_address);
that should force it to use the PHP SoapClient instead of the namespace that is presumably declared at the start of the file you're having trouble with.