group_me v0.1.1 GroupMe.Socket

Load up the Socket and start listening for messages.

Group Me Push Tutorial

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

connect_and_listen(access_token, user_id, on_data)

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)
handshake()

Start the connection process.

listen(socket, on_data)

Listen for messages. This blocks and calls the on_data callback when a message is received.

subscribe(socket, client_id, access_token, user_id)

Subscribe with your access_token and user_id using the client_id from handshake() to authenticate.