Implement WebSocket and LWSWS servers in same executable with libwebsockets - libwebsockets

I'm trying to create a Web Socket server and a LWSWS web server provided in libwebsockets v2.0.
I just need a simple web server to provide HTML/JS/CSS content to the browser and a web sockets server to work with the Web front-end.
The only doc available is really short and doesn't say anything about that, as v2.0 is brand new. The libwebsockets GitHub recommand to refer to the LWSWS example in the project, but the procedures to implement and run a server for LWSWS and a Web Socket server are not matching (the first using libuv event loop, the other using built-in libwebsockets functions).
Maybe the only solution is implementing my own http callback but I want to make sure that there's no faster solution using LWSWS.

I managed to compile and run a LWSWS server from libwebsockets, embedding an HTTP Server and a Web Socket server in the same executable.
Guidelines
Use code from example lwsws/main.c, and copy .h and .c depencies to compile an LWSWS server
Use code from example plugin-standalone/protocol_example_standalone.c to compile your protocol plugin .dll
Create a quick server and vhost configuration from lwsws/etc-lwsws-conf.d-localhost-EXAMPLE and lwsws/etc-lwsws-conf-EXAMPLE
Put compiled plugins and libs at the right spot and enjoy your server
In case it might help !

Related

How do I know if a library is server-side or client-side library?

Correct me if I am wrong, a server side library runs on a server, and a client side library runs on the user's computer.
However, how do I know if a library runs on server or client? Is there a rule of thumb?
For example, why are node.js libraries server side libraries if you install it on your local machine and run it on your local machine?
If the library is executed somewhere locally but outside of a browser, is it still considered a client side library?
I would recommend you read these two articles. They should give you some clarity on Node.js functionality and server and client side scripting.
Server VS Client
https://skillcrush.com/2012/07/30/client-side-vs-server-side/
Intro to Node.js
https://www.google.com/amp/s/opensourceforu.com/2016/01/an-introduction-to-node-js-the-server-side-javascript/amp/

Communication between Chrome javascript and native Windows code

I need to have a communication channel between my web application that runs on Chrome, and a native code on Windows. I need to run a native code when JS requests and pass the results back from native code. The environment is totally managed so I can set trusts and group policies, etc.
I can think of preparing a small web service that runs locally (and allows CORS) and call this service from javascript, but in this case i need to run this code forever.
Any advices will be very helpful. If it is possible i can try Windows registry write/read, pipes, shared memory, MMF or any other way to do it.
Thanks
There's a way to communicate with local processes without using an extension. Websockets aren't restricted to communicating with the same domain as the web page, they can communicate with a WebSocket server on localhost. You have to wrap your native code in a WebSocket server, libraries are available for that though.
Another method is Native Messaging, but it requires a browser extension:
Native messaging enables a WebExtension to exchange messages with a
native application installed on the user's computer.
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Native_messaging
https://developer.chrome.com/extensions/nativeMessaging

Can I run a http server in nativescript?

Is it possible to run an in-app HTTP server with NativeScript either as a background service or as part of the foreground app itself ? I am looking to utilize a common code base across a system of applications which would communicate to a local server which handles some parts of the application's communication to my servers. Where, I intend to create a HTTP server in the app which can just serve as a REST server for the app. Is it possible ?
Thank you.
I don't think its possible since nativescript doesn't offer any module or plugin that supports the creation of http servers. First option is to look for a nativescript module in npm that supports http server creation, Second option is to create an http server using the native API's with javascript, Third and last option (which I prefer) is to make your own server using nodejs or any server side script and run that server on a certain machine then from your nativescript app you can access that server using the fetch module or the http module :)

Is omnisharp Server similar to IIS express

Is omnisharp server similar to IIS express? Let's say I have a project folder which has only html files, I start the ominisharp server through atom text editor. It gets started and says listening at port xxxx
If I browse localhost://xxxx/index.html will it serve that file?
I am newbie please clarify
No, the point of the Omnisharp server is not to be a general purpose web server - it's to act as a service. Think of it as an "IDE service" that just happens to exposed itself over HTTP, as that's the easiest way for many clients to talk to a service.
Unless you need to integrate something with Omnisharp yourself (i.e. writing code to be a client), you can probably just think of it as a plugin for whatever you're using. (In most cases there will be an actual plugin, which then talks to Omnisharp.)

PJSIP server development

When using pjsip technology to develop a server, the official web site is a bit difficult to use when looking for a way to develop a server.
It has an introduction on how to develop a client application with the library, but not how to implement a server.
Any one direct me to some reference documentation or blob posts or other web site that can help show me how to create a pjsip based server?
You can find a sample SIP proxy implementation inside the PJSIP source code: http://trac.pjsip.org/repos/browser/pjproject/trunk/pjsip-apps/src/samples/stateful_proxy.c and http://trac.pjsip.org/repos/browser/pjproject/trunk/pjsip-apps/src/samples/stateless_proxy.c
Asterisk SCF module uses pjsip. Maybe that will shed some light
More information, visit
https://wiki.asterisk.org/wiki/display/TOP/How+to+add+a+PJSIP+module+to+Asterisk+SCF
https://wiki.asterisk.org/wiki/display/AST/SIP+Stack+Research
I think I found it. PJSUA utility in pjproject tree acts as SIP server, Zoiper Softphone successfully connects and makes calls.

Resources