WebIM
A Ruby WebIM library for nextalk.im.
Require
Ruby2.0+
Getting started
You can connect to NexTalk server by instantiating the WebIM::Client class:
require "webim"
endpoint = {:id => "uid1", :nick => "user1", :show => "available", :status => 'Online'}
client = WebIM::Client.new(endpoint, "domain", "apikey", "localhost", 8000)
Once connected, you can forward requests or route messages to the server:
# 向消息服务器转发用户上线消息,同时发送用户的好友id列表、群组id列表
client.online(['uid2','uid3', 'uid4'], ['room1', 'room2', 'room3'])
# 向消息服务器转发聊天消息
client.({:to => "uid2", :body => "hahaha"})
# 向消息服务器转发用户现场变化
client.presence('busy', "Busy")
# 向消息服务器转发用户状态,例如正在输入...
client.status("uid2", "typing", "I am typing")
# 向消息服务器push即时消息
client.({:from => "uid1", :to => "uid2", :body => "ahbh"})
# 从消息服务器读取用户现场信息
client.presences(["uid1", "uid2"])
# 向消息服务器转发用户加入群组请求
client.join('room1')
# 从消息服务器读取当前群组在线用户
client.members('room1')
# 向消息服务器转发用户离开群组请求
client.leave('room1')
# 向消息服务器转发用户下线消息
client.offline
Gem build and install
gem build webim.gemspec
gem install webim-5.8.gem