Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(socketio): add support for Socket.IO to expose WebSocket endpoints
Signed-off-by: Raymond Feng <enjoyjava@gmail.com>
- Loading branch information
1 parent
065a5d1
commit 29aab5c
Showing
18 changed files
with
1,169 additions
and
0 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Copyright (c) IBM Corp. 2020. | ||
Node module: @loopback/socketio | ||
This project is licensed under the MIT License, full text below. | ||
|
||
-------- | ||
|
||
MIT License | ||
|
||
MIT License Copyright (c) IBM Corp. 2020 | ||
|
||
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 (including the next | ||
paragraph) 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# @loopback/socketio | ||
|
||
This module uses [socket.io](http://socket.io) to expose controllers as | ||
WebSocket friendly endpoints. | ||
|
||
## Use Cases | ||
|
||
1. A real time application would like to use WebSocket friendly APIs to manage | ||
subscriptions, participants (rooms) and message exchanges. | ||
|
||
2. Make it easy for API developers to expose WebSocket friendly APIs without | ||
learning a lot of low level concepts. | ||
|
||
3. Use it as a step stone to explore messaging oriented API paradigms and | ||
programming models, such as pub/sub, eventing, streaming, and reactive. | ||
|
||
## High Level Design | ||
|
||
The package will provide the following key constructs: | ||
|
||
- SocketIOServer: A new server type that listens on incoming WebSocket | ||
connections and dispatches messages to controllers that subscribe to the | ||
namespace. Each server is attached to an http/https endpoint. | ||
|
||
- SocketIO controller: A controller class that is decorated with SocketIO | ||
related metadata, including: | ||
|
||
- Map to a namespace | ||
- Connect/disconnect events | ||
- Subscribe/consume messages | ||
- Publish/produce messages | ||
|
||
- SocketIO middleware or sequence | ||
- Allow common logic to intercept/process WebSocket messages | ||
|
||
## Basic Use | ||
|
||
1. Create a SocketIOServer | ||
2. Define a controller to handle socket.io events/messages | ||
3. Register the controller | ||
4. Discover socket.io controllers and mount them to the SocketIOServer | ||
namespaces. | ||
|
||
## Installation | ||
|
||
```sh | ||
npm install --save @loopback/socketio | ||
``` | ||
|
||
## Contributions | ||
|
||
- [Guidelines](https://github.com/strongloop/loopback-next/blob/master/docs/CONTRIBUTING.md) | ||
- [Join the team](https://github.com/strongloop/loopback-next/issues/110) | ||
|
||
## Tests | ||
|
||
Run `npm test` from the root folder. | ||
|
||
## Contributors | ||
|
||
See | ||
[all contributors](https://github.com/strongloop/loopback-next/graphs/contributors). | ||
|
||
## License | ||
|
||
MIT |
Oops, something went wrong.