Skip to content

Commit

Permalink
simplified further
Browse files Browse the repository at this point in the history
  • Loading branch information
Raynos committed Aug 8, 2012
1 parent 9cd6a29 commit 7d68148
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
20 changes: 11 additions & 9 deletions README.md
Expand Up @@ -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
Expand All @@ -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`
Expand Down
14 changes: 5 additions & 9 deletions 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)
}
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -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": [
{
Expand Down

0 comments on commit 7d68148

Please sign in to comment.