Skip to content

Commit

Permalink
Refactored 'http' module implementation API; Refactored helloworld an…
Browse files Browse the repository at this point in the history
…d README accordingly
  • Loading branch information
tristanls committed Dec 18, 2011
1 parent e3922e5 commit 6c0aa94
Show file tree
Hide file tree
Showing 4 changed files with 379 additions and 124 deletions.
32 changes: 18 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,29 @@ anode = require 'anode'

cnf = new anode.Configuration()

http_actor = cnf.actor anode.http.http_beh()
helloworld = cnf.actor anode.behavior(
'http, #created, server' : ->
@send( @, '#listen', 8080, '127.0.0.1' ).to @server
'server, #listening, port, host' : ->
@send( 'Server running at http://' + @host + ':' + @port + '/' ).to cnf.console.log
'server, #request, request, response' : ->
@send( null, '#end', 'Hello Actor World\n' ).to @response
)()

cnf.send( helloworld, '#createServer' ).to http_actor
httpServer = cnf.actor anode.http.server_beh()
helloworld = cnf.actor anode.behavior( 'httpServer'

'#start' : ->
@send( @, '#listen', 8080, '127.0.0.1' ).to @httpServer

'$httpServer, #listen' : ->
@send( 'Server running at http://127.0.0.1:8080/' ).to cnf.console.log

'$httpServer, #request, request, response' : ->
@send( null, '#end', 'Hello Actor World\n' ).to @response

)( httpServer ) # helloworld

cnf.send( '#start' ).to helloworld
```

To run the server, go into the `examples` directory and execute it with `coffee`:

'% coffee helloworld.example.coffee
% coffee helloworld.example.coffee
Server running at http://127.0.0.1:8080/

*note: not all of the `node` `'http'` functionality has been wrapped yet.
*note: not all of the Node.js `'http'` functionality has been wrapped yet.

### Actors

Expand Down Expand Up @@ -82,7 +86,7 @@ Other examples show simpler functionality:

(The MIT License)

Copyright (c) 2011 Tristan Slominski <tristan.slominski@gmail.com>
Copyright (c) 2011 Tristan Slominski

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
25 changes: 11 additions & 14 deletions examples/helloworld.example.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,20 @@ anode = require '../lib/anode'
cnf = new anode.Configuration()

# create the http actor
http_actor = cnf.actor anode.http.http_beh()
httpServer = cnf.actor anode.http.server_beh()

# create the hello world actor
helloworld = cnf.actor anode.beh(
# create the hello world application actor
helloworld = cnf.actor anode.beh( 'httpServer'

'http, #created, server' : ->
@send( @, '#listen', 8080, '127.0.0.1' ).to @server

'server, #listening, port, host' : ->
@send( 'Server running at http://' + @host + ':' + @port + '/' ).to \
cnf.console.log
'#start' : ->
@send( @, '#listen', 8080, '127.0.0.1' ).to @httpServer

'$httpServer, #listen' : ->
@send( 'Server running at http://127.0.0.1:8080/' ).to cnf.console.log

'server, #request, request, response' : ->
'$httpServer, #request, request, response' : ->
@send( null, '#end', 'Hello Actor World\n' ).to @response

)() # helloworld
)( httpServer ) # helloworld

# send the #createServer message to http actor with helloworld as the customer
# for the '#created' message
cnf.send( helloworld, '#createServer' ).to http_actor
cnf.send( '#start' ).to helloworld
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name" : "anode",
"description" : "Humus inspired actor framework for Node.js",
"version" : "0.1.5",
"version" : "0.2.0",
"author" : "Tristan Slominski <tristan.slominski@gmail.com>",
"contributors" : [
"Dale Schumacher <dale.schumacher@gmail.com>"
Expand Down
Loading

0 comments on commit 6c0aa94

Please sign in to comment.