项目作者: forsaken1

项目描述 :
Small analog socket.io
高级语言: Crystal
项目地址: git://github.com/forsaken1/socket-io.cr.git
创建时间: 2016-03-16T14:57:38Z
项目社区:https://github.com/forsaken1/socket-io.cr

开源协议:MIT License

下载


SocketIO

Small analog socket.io

Installation

Add this to your application’s shard.yml:

  1. dependencies:
  2. socket_io:
  3. github: forsaken1/socket-io.cr

Usage

With Kemal:

  1. require "kemal"
  2. require "socket_io"
  3. socket_io = SocketIO::Base.new
  4. handler = socket_io.on_connection do |session| # session : SocketIO::WebSocket
  5. session.on("client_event") do |message|
  6. puts message
  7. session.emit("some_event", { message: "Hello!" })
  8. end
  9. end
  10. socket_io.emit :tick, { array: [1, 2, 3, 4], hash: { field: "Field" } } # send to all client
  11. Kemal.config.add_handler handler
  12. Kemal.run

On client

Use JS analog SocketIO.js

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 Krylov Alexey - creator, maintainer