Skip to content
Browse files

simplified further

  • Loading branch information...
1 parent 9cd6a29 commit 7d681484964bfec2816902785a9e52dbc7c78f72 @Raynos committed Aug 8, 2012
Showing with 18 additions and 19 deletions.
  1. +11 −9 README.md
  2. +5 −9 examples/simple/magic.js
  3. +2 −1 package.json
View
20 README.md
@@ -16,6 +16,8 @@ stream.on("data", console.log.bind(console, "[BROWSER]"))
stream.write("hello from browser!")
```
+Create a client connection to the seaport server as long as the seaport proxy is running on the server.
+
## Server example
``` js
@@ -29,28 +31,28 @@ sock.install(someHttpServer, '/boot')
console.log("sock hooked on", "/boot")
```
+Creates a seaport proxy on the server so that the browser can talk to seaport.
+
## Magic service
``` js
-var seaport = require("seaport")
+var seaport = require("seaport-stream")
, net = require("net")
var ports = seaport.connect("localhost", 9093)
ports.service("magic@1.2.3", createMagic)
-function createMagic(port, done) {
- var server = net.createServer(function (stream) {
- stream.write("hello from magic!")
- stream.on("data", function (data) {
- console.log("[MAGIC]", data.toString())
- })
+function createMagic(stream) {
+ stream.write("hello from magic!")
+ stream.on("data", function (data) {
+ console.log("[MAGIC]", data.toString())
})
- server.listen(port, done)
- console.log("magic service hooked on port", port)
}
```
+Expose a service over seaport that the browser can talk to. Use seaport-stream because you don't care about the IO and only about the stream
+
## Installation
`npm install seaport-proxy`
View
14 examples/simple/magic.js
@@ -1,17 +1,13 @@
-var seaport = require("seaport")
+var seaport = require("seaport-stream")
, net = require("net")
var ports = seaport.connect("localhost", 9093)
ports.service("magic@1.2.3", createMagic)
-function createMagic(port, done) {
- var server = net.createServer(function (stream) {
- stream.write("hello from magic!")
- stream.on("data", function (data) {
- console.log("[MAGIC]", data.toString())
- })
+function createMagic(stream) {
+ stream.write("hello from magic!")
+ stream.on("data", function (data) {
+ console.log("[MAGIC]", data.toString())
})
- server.listen(port, done)
- console.log("magic service hooked on port", port)
}
View
3 package.json
@@ -29,7 +29,8 @@
"browserify": "~1.14.5",
"ecstatic": "~0.1.6",
"routes": "~0.1.1",
- "browserify-server": "0.0.1"
+ "browserify-server": "0.0.1",
+ "seaport-stream": "0.0.1"
},
"licenses": [
{

0 comments on commit 7d68148

Please sign in to comment.
Something went wrong with that request. Please try again.