https://github.com/sunng87/link-socketio
Socketio server with link API
https://github.com/sunng87/link-socketio
Last synced: 8 months ago
JSON representation
Socketio server with link API
- Host: GitHub
- URL: https://github.com/sunng87/link-socketio
- Owner: sunng87
- License: epl-1.0
- Created: 2014-06-06T15:21:38.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-07-07T09:13:57.000Z (over 11 years ago)
- Last Synced: 2025-04-19T07:09:39.973Z (9 months ago)
- Language: Clojure
- Size: 234 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# link-socketio
SocketIO server with [link](https://github.com/sunng87/link) verbs,
based on
[Nikita Koksharov's netty-socketio](https://github.com/mrniko/netty-socketio).
link-socketio 0.2 based on netty-socketio `1.7.x` now supports
SocketIO protocol 1.0. There are some breaking changes compared with 0.1.
link-socketio 0.1 is based on netty-socketio `1.6.5`, implements
SocketIO protocol till 0.9.
## Usage
### Leiningen

### Server Handlers
We only support `connect`, `disconnect` and `message` in 0.1. As all
data type changed to `event` in SocketIO 1.0, I might not support
`json` or `event` of 0.9 protocol. Use it at your own risk.
All handlers are defined in [link](https://github.com/sunng87/link)
style.
```clojure
(refer-clojure :exclude '[send])
(require '[link.core :refer [send remote-addr id close]])
(require '[link.socketio :refer :all])
(import '[java.util Map])
(def default-handler
(create-handler
(on-connect [ch]
(println "on connect" (id ch) (remote-addr ch)))
;; on-event macro arguments
;; 1. event name
;; 2. serialized type, typically in clojure we use Map here
;; and from 0.2, the data we sent must be a map contains :event and :data
(on-event "test" Map [ch msg]
(send ch {:event "test"
:data "Greeting from server!")
(println "on message" ch msg)
(close ch))
(on-disconnect [ch]
(println "on disconnect" ch))))
```
The `SocketIOClient` now extends protocol `LinkMessageChannel` so it
supports [link](https://github.com/sunng87/link) verbs:
* id
* send
* send*
* remote-addr
* close
## License
Copyright © 2014 Sun Ning
Distributed under the Eclipse Public License either version 1.0 or (at
your option) any later version.