Giter VIP home page Giter VIP logo

ccws's Introduction

ccws - ChakraCore powered WebSocket Server

build status

ccws is a lightweight linux-only web(socket)-server. It is the spiritual successor to my previous project besenws and currently under heavy construction. Under no way it is encouraged to use this software in a productive or public environment.

It is made possible with

Building

Checkout with submodules. Build using Lazarus (or lazbuild), or fpc itself if you manage to figure out the required parameters. libChakraCore.so must be placed in /lib and can be obtained here

Running

ccws will fork to the background and run as a service by default. Parameter -debug will keep it in foreground. It runs just fine in Windows Subsystem For Linux (WSL)!

Usage

ccws is organized in sites, which can be bound to one or more hosts - configuration is done in settings.js, which is worth to look at. A site can host one or more websocket scripts which are bound to a specific endpoint. Each script runs in its own context and thread. The global handler object has different callbacks that you should implement:

callback signature Description
handler.onConnect function(client) Fired when a new websocket client connects.
handler.onData function(client, data) Fired when a websocket packet is received from a client.
handler.onDisconnect function(client) Fired when a websocket client is disconnected.
handler.onRequest function(client) Fired when a regular http request is made. The connection remains open and no response is sent until client.disconnect() is called.

The client object implements various methods and properties for an existing connection:

method/property Description
send(data) sends a websocket packet to the client
disconnect() disconnects the client
getHeader(key) returns an entry from the request header
redirect(url) redirects a http request to the specified url
host the client ip address. read-only.
lag current lag of the websocket connection. only updated during idle pings. read-only.
postData data from an eventual POST request (http request only). read-only.
pingTime websocket ping interval. Sent after x ms of idle time
maxPongTime websocket ping time-out value. clients who fail to respond in time will be disconnected (this is handled by the websocket protocol, no client implementation is required)
mimeType the mime type for a http response. defaults to text/html
returnType the http response message. defaults to 200 OK
parameter the URI request parameter

Further documentation and implementation details is still work in progress and subject to change.

Web Server

ccws can also serve static files, but you're encouraged to use a different webserver for this purpose, and use a reverse ssl proxy to only expose selected endpoints.

ccws's People

Contributors

reddor avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.