group_me v0.1.1 GroupMe.Socket
Load up the Socket and start listening for messages.
GroupMe uses the Ruby Faye implementation of Sockets. (https://github.com/faye/faye-websocket-ruby)[https://github.com/faye/faye-websocket-ruby]
You will probably want this in a process or task of some sort.
Example:
Task.async(fn()->
GroupMe.Socket.connect_and_listen("<token>", "<user_id>", fn(d) ->
IO.inspect(hd(d)["data"]["alert"])
end)
end)
Summary
Functions
Handle the handshake, subscription, and blocks while waiting for new messages
Start the connection process
Listen for messages. This blocks and calls the on_data
callback when a message is received
Subscribe with your access_token
and user_id
using the client_id
from handshake()
to authenticate
Functions
Handle the handshake, subscription, and blocks while waiting for new messages.
Pass a callback on_data
to take actions based on the message data.
Example:
GroupMe.Socket.connect_and_listen("<token>", "<user_id>", fn(d) ->
IO.inspect(hd(d)["data"]["alert"])
end)
Listen for messages. This blocks and calls the on_data
callback when a message is received.