krishamoud / meteor-slack-api

This is the entire slack api written for meteor. Both synchronous and asynchronous calls available.
MIT License
16 stars 8 forks source link

how to use the rtm start? #2

Open dcsan opened 9 years ago

dcsan commented 9 years ago

for the official API you can use

slack = new Slack(token, autoReconnect, autoMark)

I'm wondering if you've gone through the steps to get a websocket going after the API

SlackAPI.rtm.start(token, callback)

The url property contains a WebSocket Message Server URL. Connecting to this URL will initiate a Real Time Messaging session. These URLs are only valid for 30 seconds, so connect quickly!

about to start looking into that but asking here first!

Meteor.startup ->
  if Meteor.isServer
    slack = SlackAPI.rtm.start(token, startCb)

startCb = (err, res) ->
  console.log("slack.start", err, res)
  if err
    console.error("cant start slack.rtm")
  else
    slack = res

   # do something with it
dcsan commented 9 years ago

I got as far as using joncursi:socket-io-client and

slack = new io(res.url)

but can't seem to get any events to trigger on the connection...

krishamoud commented 9 years ago

This api will not automatically connect you to the real time messaging. It will only return the url. I can look into making this automatic.

dcsan commented 9 years ago

Do you have a code sample of how you're using that URL?

AFAI understand opening the connection requires a Websocket which requires importing other node packages, unless i'm missing something.