socket-io.cr
SocketIO
Small analog socket.io
Installation
Add this to your application's shard.yml
:
dependencies:
socket_io:
github: forsaken1/socket-io.cr
Usage
With Kemal:
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
Contributing
- Fork it ( https://github.com/forsaken1/socket-io.cr/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- forsaken1 Krylov Alexey - creator, maintainer
Repository
socket-io.cr
Owner
Statistic
- 6
- 1
- 0
- 0
- 0
- about 8 years ago
- March 16, 2016
License
MIT License
Links
Synced at
Sun, 17 Nov 2024 17:09:03 GMT
Languages