All Projects → SocketCluster → Socketcluster Server

SocketCluster / Socketcluster Server

Licence: mit
Minimal server module for SocketCluster

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Socketcluster Server

Clusterws
💥 Lightweight, fast and powerful framework for building scalable WebSocket applications in Node.js
Stars: ✭ 868 (+1140%)
Mutual labels:  server, websocket, realtime, socket
Clusterws Client Js
🔥 JavaScript Client for ClusterWS - lightweight, fast and powerful framework for building scalable WebSocket applications in Node.js.
Stars: ✭ 120 (+71.43%)
Mutual labels:  websocket, realtime, socket
Glass Isc Dhcp
Glass - ISC DHCP Server Interface
Stars: ✭ 486 (+594.29%)
Mutual labels:  server, websocket, realtime
Sandstone
PHP microframework designed to build a RestApi working together with a websocket server. Build a real time RestApi!
Stars: ✭ 98 (+40%)
Mutual labels:  websocket, websockets, realtime
Jstp
Fast RPC for browser and Node.js based on TCP, WebSocket, and MDSF
Stars: ✭ 132 (+88.57%)
Mutual labels:  server, websocket, socket
Butterfly Server
The Everything is Real-Time C# Backend for Single Page Applications
Stars: ✭ 247 (+252.86%)
Mutual labels:  server, websocket, realtime
Aiowebsocket
Async WebSocket Client. Advantage: Flexible Lighter and Faster
Stars: ✭ 263 (+275.71%)
Mutual labels:  websocket, websockets, socket
Beast
HTTP and WebSocket built on Boost.Asio in C++11
Stars: ✭ 3,241 (+4530%)
Mutual labels:  server, websocket, websockets
Bigq
Messaging platform in C# for TCP and Websockets, with or without SSL
Stars: ✭ 18 (-74.29%)
Mutual labels:  websocket, websockets, socket
C10k Server
A toy asynchronous server, written in C++14 (WIP)
Stars: ✭ 14 (-80%)
Mutual labels:  server, socket
Tinytcpserver
A small tcp server working under Mono or .NET (4.0) and provides hooks for handling data exchange with clients (works under mono and .net). Behaviour/protocol/reaction could be specified via custom C# script.
Stars: ✭ 14 (-80%)
Mutual labels:  server, socket
Rtb
Benchmarking tool to stress real-time protocols
Stars: ✭ 35 (-50%)
Mutual labels:  websocket, realtime
Channelslightscontrol
Demo app with Django Channels to control Lights over websockets. Made for PyStPete meetup(https://www.meetup.com/Saint-Petersburg-Python-Meetup/).
Stars: ✭ 14 (-80%)
Mutual labels:  websockets, realtime
Deepstream.io
deepstream.io server
Stars: ✭ 6,947 (+9824.29%)
Mutual labels:  websocket, realtime
Zeus
A high performance, cross-platform Internet Communication Engine. Developed with native socket API. Aim at handling millions of concurrent connections.
Stars: ✭ 30 (-57.14%)
Mutual labels:  server, socket
Clientserverproject
一个C-S模版,该模版由三部分的程序组成,一个服务端运行的程序,一个客户端运行的程序,还有一个公共的组件,实现了基础的账户管理功能,版本控制,软件升级,公告管理,消息群发,共享文件上传下载,批量文件传送功能。具体的操作方法见演示就行。本项目的一个目标是:提供一个基础的中小型系统的C-S框架,客户端有三种模式,无缝集成访问,winform版本,wpf版本,asp.net mvc版本,方便企业进行中小型系统的二次开发和个人学习。同时网络组件方便的支持读写三菱和西门子PLC的数据,详细见Readme
Stars: ✭ 873 (+1147.14%)
Mutual labels:  server, socket
Mean Angular4 Chat App
MEAN stack with Angular 4 Chat App
Stars: ✭ 41 (-41.43%)
Mutual labels:  websocket, socket
Embedio
A tiny, cross-platform, module based web server for .NET
Stars: ✭ 1,007 (+1338.57%)
Mutual labels:  websocket, websockets
Progress Bot
High-tech weaponized moe progress delivery bot for IRC, Discord, and web
Stars: ✭ 38 (-45.71%)
Mutual labels:  realtime, socket
Convergence Server
The Convergence Server
Stars: ✭ 44 (-37.14%)
Mutual labels:  server, realtime

SocketCluster server

Minimal server module for SocketCluster.

This is a stand-alone server module for SocketCluster. SocketCluster's protocol is backwards compatible with the SocketCluster protocol.

Setting up

You will need to install both socketcluster-server and socketcluster-client (https://github.com/SocketCluster/socketcluster-client).

To install this module:

npm install socketcluster-server

Usage

You need to attach it to an existing Node.js http or https server (example):

const http = require('http');
const socketClusterServer = require('socketcluster-server');

let httpServer = http.createServer();
let agServer = socketClusterServer.attach(httpServer);

(async () => {
  // Handle new inbound sockets.
  for await (let {socket} of agServer.listener('connection')) {

    (async () => {
      // Set up a loop to handle and respond to RPCs for a procedure.
      for await (let req of socket.procedure('customProc')) {
        if (req.data.bad) {
          let error = new Error('Server failed to execute the procedure');
          error.name = 'BadCustomError';
          req.error(error);
        } else {
          req.end('Success');
        }
      }
    })();

    (async () => {
      // Set up a loop to handle remote transmitted events.
      for await (let data of socket.receiver('customRemoteEvent')) {
        // ...
      }
    })();

  }
})();

httpServer.listen(8000);

For more detailed examples of how to use SocketCluster, see test/integration.js. Also, see tests from the socketcluster-client module.

SocketCluster can work without the for-await-of loop; a while loop with await statements can be used instead. See https://github.com/SocketCluster/stream-demux#usage

Compatibility mode

For compatibility with existing SocketCluster clients, set the protocolVersion to 1 and make sure that the path matches your old client path:

let agServer = socketClusterServer.attach(httpServer, {
  protocolVersion: 1,
  path: '/socketcluster/'
});

Running the tests

  • Clone this repo: git clone [email protected]:SocketCluster/socketcluster-server.git
  • Navigate to project directory: cd socketcluster-server
  • Install all dependencies: npm install
  • Run the tests: npm test

Benefits of async Iterable over EventEmitter

  • More readable: Code is written sequentially from top to bottom. It avoids event handler callback hell. It's also much easier to write and read complex integration test scenarios.
  • More succinct: Event streams can be easily chained, filtered and combined using a declarative syntax (e.g. using async generators).
  • More manageable: No need to remember to unbind listeners with removeListener(...); just break out of the for-await-of loop to stop consuming. This also encourages a more declarative style of coding which reduces the likelihood of memory leaks and unintended side effects.
  • Less error-prone: Each event/RPC/message can be processed sequentially in the same order that they were sent without missing any data; even if asynchronous calls are made inside middleware or listeners. On the other hand, with EventEmitter, the listener function for the same event cannot be prevented from running multiple times in parallel; also, asynchronous calls within middleware and listeners can affect the final order of actions; all this can cause unintended side effects.

License

(The MIT License)

Copyright (c) 2013-2019 SocketCluster.io

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].