jcoglan/faye — Issue #99: Weird behaviour when I send immediately after creating a client
Author: josephg
Created: 2011-10-08 09:15:09+00:00
State: open

```coffeescript
faye = require 'faye'

bayeux = new faye.NodeAdapter mount: '/faye', timeout: 45
bayeux.listen 8001
console.log 'bayeax listening on 8001'

bayeux.addExtension
incoming: (message, callback) ->
console.log 'server incoming', message if message.data == 'hi there'
callback(message)
outgoing: (message, callback) ->
console.log 'server outgoing', message if message.data == 'hi there'
callback(message)

bayeux.getClient().subscribe '/x', (msg) -> console.log 'server received message', msg

c = new faye.Client 'http://localhost:8001/faye'

c.addExtension
incoming: (message, callback) ->
console.log 'client incoming', message if message.data == 'hi there'
callback(message)
outgoing: (message, callback) ->
console.log 'client outgoing', message if message.data == 'hi there'
callback(message)

c.subscribe '/x', (msg) -> console.log 'client received message', msg
c.publish '/x', 'hi there'
```

If I do this, the `'hi there'` message is received by the server, but never received by the client.

The output is this:

```
$ coffee noop.coffee
bayeax listening on 8001
client outgoing { channel: '/x',
data: 'hi there',
clientId: '0qxu0jh07ixk8y1j2ltv30fky347',
id: '2' }
server incoming { channel: '/x',
data: 'hi there',
clientId: '0qxu0jh07ixk8y1j2ltv30fky347',
id: '2' }
server outgoing { channel: '/x',
data: 'hi there',
clientId: '0qxu0jh07ixk8y1j2ltv30fky347',
id: '2' }
server received message hi there
```