https://github.com/forsaken1/socket-io.cr
Small analog socket.io
https://github.com/forsaken1/socket-io.cr
library websockets
Last synced: 9 months ago
JSON representation
Small analog socket.io
- Host: GitHub
- URL: https://github.com/forsaken1/socket-io.cr
- Owner: forsaken1
- License: mit
- Created: 2016-03-16T14:57:38.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-10-17T14:18:04.000Z (over 9 years ago)
- Last Synced: 2025-05-12T23:46:46.682Z (about 1 year ago)
- Topics: library, websockets
- Language: Crystal
- Homepage:
- Size: 5.86 KB
- Stars: 6
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SocketIO
Small analog socket.io
## Installation
Add this to your application's `shard.yml`:
```yaml
dependencies:
socket_io:
github: forsaken1/socket-io.cr
```
## Usage
With [Kemal](http://kemalcr.com):
```crystal
require "kemal"
require "socket_io"
socket_io = SocketIO::Base.new
handler = socket_io.on_connection do |session| # session : SocketIO::WebSocket
session.on("client_event") do |message|
puts message
session.emit("some_event", { message: "Hello!" })
end
end
socket_io.emit :tick, { array: [1, 2, 3, 4], hash: { field: "Field" } } # send to all client
Kemal.config.add_handler handler
Kemal.run
```
## On client
Use JS analog [SocketIO.js](https://gist.github.com/forsaken1/6223ed86422c0996634b)
## Contributing
1. Fork it ( https://github.com/forsaken1/socket-io.cr/fork )
2. Create your feature branch (git checkout -b my-new-feature)
3. Commit your changes (git commit -am 'Add some feature')
4. Push to the branch (git push origin my-new-feature)
5. Create a new Pull Request
## Contributors
- [forsaken1](https://github.com/forsaken1) Krylov Alexey - creator, maintainer