GithubHelp home page GithubHelp logo

pusher-lite's People

Contributors

abhishiv avatar dirkbonhomme avatar kevinsawicki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

pusher-lite's Issues

Assumption that payload data is always JSON

There is assumption that message payload is JSON:
https://github.com/abhishiv/pusher-node-client/blob/master/lib/pusher-node-client.coffee#L117

Error I getting is:

SyntaxError: Unexpected number
  at Object.parse (native)
  at PusherClient.recieveMessage (/home/xxx/local/node/lib/node_modules/pusher-node-client/lib/pusher-node-client.js:175:51)
  at PusherClient.recieveMessage (/home/xx/local/node/lib/node_modules/pusher-node-client/lib/pusher-node-client.js:6:61)
  at WebSocketConnection.<anonymous> (/home/xxx/local/node/lib/node_modules/pusher-node-client/lib/pusher-node-client.js:140:24)
  at WebSocketConnection.emit (events.js:95:17)
  at WebSocketConnection.processFrame (/home/xxx/local/node/lib/node_modules/pusher-node-client/node_modules/websocket/lib/WebSocketConnection.js:356:26)
  at WebSocketConnection.handleSocketData (/home/xxx/local/node/lib/node_modules/pusher-node-client/node_modules/websocket/lib/WebSocketConnection.js:205:14)
  at CleartextStream.emit (events.js:95:17)
  at CleartextStream.<anonymous> (_stream_readable.js:764:14)
  at CleartextStream.emit (events.js:92:17)
  at emitReadable_ (_stream_readable.js:426:10)
  at _stream_readable.js:419:7
  at process._tickCallback (node.js:419:13)

In my case payload is just a string, not a valid JSON.
The payload is a strings like "00012345|0006789".
The error is:

JSON.parse("00012345|0006789")
SyntaxError: Unexpected number
    at Object.parse (native)
    at repl:1:7
    at REPLServer.self.eval (repl.js:110:21)
    at Interface.<anonymous> (repl.js:239:12)
    at Interface.emit (events.js:95:17)
    at Interface._onLine (readline.js:202:10)
    at Interface._line (readline.js:531:8)
    at Interface._ttyWrite (readline.js:760:14)
    at ReadStream.onkeypress (readline.js:99:10)
    at ReadStream.emit (events.js:98:17)

One solution is to add additional argument to channel.subscribe function, which will be indicating that there is no need to treat message payloads as JSON.

PusherClient#resetActivityCheck not actually disconnecting

Hi there!

I'm using this library to communicate with Pusher from a Mac server. Unfortunately, when the server goes to sleep and is woken back up, the resetActivityCheck method calls its waitingTimeout. This wouldn't be a big deal, except the waitingTimeout doesn't actually seem to disconnect; it only unsubscribes from the connected channels. Here's the relevant code (from lib/pusher-node-client.coffee):

@waitingTimeout = setTimeout(
  () =>
    console.log "disconnecting because of inactivity at #{(new Date).toLocaleTimeString()}"
    _(@channels).each (channel) =>
        @unsubscribe channel.channel_name, channel.channel_data
    console.log "connetcing again at #{(new Date).toLocaleTimeString()}"
    if @connection.state isnt "open"
      @connect()
  30000
)

Is this intended behavior? If so, it would probably make sense to emit another event, so consumer code can know it should attempt to reconnect to any appropriate channels. If you'd like, I can make this change and submit a PR, or you can let me know if there's another solution you'd like implemented.

Thanks!
-paul

Channel Authentication endpoint

Hello
following pusher API documentation, we can set authentication endpoint for presence- and private- channels. Maybe I overlooked ability to set it when reviewing code, but I did not found it.
Cheers
Michael

Proxy support is missing

Could you please add proxy support.
To proxy websockets I'm using faye-websocket with the following options {proxy:{ origin: wsProxyUrl},ping: XX}.
I guess for pure websockets the implementation is difficult.

Cannot call method 'sendUTF' of undefined

just using subscribe - cant work as connection is never defined as a property of the object anywhere in the codebase.

library has been unmaintained for years, no surprise it was unfinished - pathetic its listed officially by Pusher.com

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.