This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import java.net.InetSocketAddress; | |
import java.net.ServerSocket; | |
// import java.net.StandardSocketOptions; | |
import java.nio.ByteBuffer; | |
import java.nio.channels.CancelledKeyException; | |
import java.nio.channels.ReadableByteChannel; | |
import java.nio.channels.SelectionKey; | |
import java.nio.channels.Selector; | |
import java.nio.channels.ServerSocketChannel; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
subscribe: () -> | |
context = @context | |
spire = @context.spire | |
iteration = @context.iteration | |
spire.messages.subscribe "channel #{iteration}", {maxCallCount: 1}, | |
(error,messages) -> | |
if error | |
context.error(error) | |
return |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[dan@yoda shark (stubby*)]$ cake test | |
test - run all the shark tests | |
test:dispatcher - run all the dispatcher specs | |
build - compile coffee script source files and copy them into lib | |
Waiting one second to make sure task 'build' has completed | |
Running on 127.0.0.1, port 1337 | |
Response URL defined as http://localhost:1337/ | |
Checking long-polling ... | |
√ [Account: creation (POST)] Result: includes an account key | |
√ [Account: delete (DELETE)] Result: the delete was successful |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s = this; s.API.discovery "http://localhost:1337/", (description) -> | |
s.Account.create description, (account) -> | |
channel_name = "Foo"; message = "Hello, World!" | |
s.Session.create [description, account], (session) -> | |
s.Channel.create [description,session.channels,channel_name], | |
(channel) -> | |
s.Channel.publish [description,channel,message] | |
# Okay, now create another session and get the message | |
s.Session.create [description, account], (session) -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a.accept "subscription", (a) -> | |
a.describe "Create a subscription" | |
a.contentType "subscription", (a) -> | |
a.run (object) -> | |
context = this | |
manager = new Channel.Manager | |
manager.on "success",(channel) -> | |
create = CREATE Subscription, (subscription) -> | |
subscription.url = context.url("subscription", [ | |
context.workspace.captured.sessionID |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env coffee | |
Server = require("../../lib/shark/http_server") | |
Adapter = require("../../lib/shark/http_adapter") | |
configuration = require("../conf/server.conf") | |
configuration.processor = (server) -> | |
adapter = new Adapter(server) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// So we start with a function that will allow to create new functions that | |
// convert errors into events. | |
var safeFactory = function(emitter) { | |
return function(fn) { | |
return function(err,value) { | |
if (err) { emitter.emit("error",err); } | |
else fn(value); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shred.post({ | |
url: description.resources.session.resources.channels.url, | |
headers: { | |
accept: description.schema["1.0"].channel.mediaType, | |
content_type: description.schema["1.0"].channel.mediaType, | |
authorization: "Capability " + | |
description.resources.session.resources.channels.capability | |
}, | |
content: { | |
name: "Foo", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Acme::Web::Adapters::Article < Acme::Web::Adapter | |
resource Acme::Resources::Article | |
Comments = Acme::Web::Adapters::Comments | |
version "1.0" do | |
path "article", :name | |
get [ json, xml, html ] | |
authorized do | |
put json => json, xml => xml | |
delete | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo gem install waves | |
waves generate -t classic -n myapp | |
cd myapp | |
waves server |