Comments (3)
Hi @SteMMo33 ,
I'm sorry for the late response, I'm on vacation and don't have access to my computer on a regular basis.
I think I see the problem, but I'm not not sure... I don't know what example you are pointing to, but it could be that the example uses the 0.5.x version API instead of the 0.6.x version API.
In the new API please use the facil_attach
function to connect the uuid
to the protocol_s
object.
Please note that the facil_attach
function should be called within the .on_open
callback.
If you have any more questions, please let me know. I'll answer as soon as I can.
Kindly,
Bo.
from facil.io.
Hi Bo,
thanks a lot for your reply.
The example is the basic echo server.
I added the facil_attach function and now the app is alive.
I'd like to handle some websocket messages sent by a browser. If I open the connection from a browser the following is the output to the console (I've added some debug fprintfs):
mora@ubuntu-virtualbox:~/Desktop/Socket/facil.io$ LD_LIBRARY_PATH=. ./ioServer
* Listening on port 7681
onProtStart
Server is running 1 worker X 10 threads, press ^C to stop
* Detected capacity: 4096 open file limit
* Root pid: 4736
New connection 0x7f0238000b20 for socket UUID 0x801
protOnReady 0x7f0238000b20 0x801
protOnReady 0x7f0238000b20 0x801
data 0x7f0238000b20 0x801:
<Echo: GET / HTTP/1.1
Host: 127.0.0.1:7681
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-GB,en;q=0.5
Accept-Encoding: gzip, deflate
Sec-WebSocket-Version: 13
Origin: null
Sec-WebSocket-Protocol: lws-minimal
Sec-WebSocket-Extensions: permessage-deflate
Sec-WebSocket-Key: BOw0PlOXkfSD4ZSiDzBxqA==
Connection: keep-alive, Upgrade
Pragma: no-cache
Cache-Control: no-cache
Upgrade: websocket
>
protOnReady 0x7f0238000b20 0x801
protOnReady 0x7f0238000b20 0x801
Freed Echo protocol at 0x7f0238000b20
In my understanding the library shoud handle the initial autentication for the websocket, is it?
I'd like to handle only the hi-level messages between server and browser.
Is it possible with your library??
what is the purpose of the onReady callback ?
thanks again,
regards :)
PS: RedSox #1 :))
from facil.io.
@SteMMo33 Hello,
Yes, the example code you chose is from the core module (included through facil.h
). The example uses plain TCP/IP sockets (without the extra WebSocket protocol).
The WebSocket protocol is part of the HTTP and WebSockets module, which you can use by including the http.h
header.
A WebSockets example should available on the Website.
Like many of the examples, the API in the example is dependent on the release version.
I believe the API on the website reflects the latest 0.6.x release, but it might be updated soon to use the master branch (the upcoming 0.7.0 release API) which includes some changes to the pub/sub logic and API.
As for the on_ready
callback:
The on_ready
callback is "called when the socket is ready to be written to". Which basically means that once the user buffer is empty and the kernel's socket buffer has some empty space (all the previous calls to sock_write
are done writing to the socket's outgoing buffer), the callback is called.
The callback behaves the same with WebSocket connections, which use websocket_write
to "pack" and send the data using the WebSocket protocol.
You don't have to use it.
Bo.
from facil.io.
Related Issues (20)
- A route handler for Facil.io
- Build facil.io into an DLL? HOT 4
- Compile on Apple Silicon M1 HOT 3
- In the example there is facil_run but I don't see this function? HOT 2
- Do you need a main() function if you are just building the shared object library? HOT 1
- fiobj_mustache.c: No folder argument HOT 1
- Passing variables to Mustache does not seem to work HOT 4
- Support for redis UNIX sockets HOT 1
- How to install this framework?
- Potential concurrency issue? Wrong file names on some requests. HOT 4
- crashed on FIOBJ_TYPE_IS(fiobj_null(), FIOBJ_T_NUMBER) HOT 2
- C++ compilation support? HOT 2
- Facil and linux epoll HOT 2
- How to receive an img file? HOT 1
- make breaking on macos m1 HOT 1
- compiling facil to shared library to be called from julia HOT 16
- trying to build native binaries for julia HOT 4
- Get form parameter
- Unlimited threads in facil.io - 0.7.x HTTP / WebSockets Server HOT 1
- OpenSSL Not Detected HOT 4
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 facil.io.