webim

A Ruby webim library for the nextalk.im.

Getting started

You can connect to NexTalk server by instantiating the Webim::Client class:

require "webim"

user = {:id => "vid:1", :nick => "user1", :show => "available", :status => 'Online'}
client = Webim::Client.new(user, "", {:domain => "localhost", :apikey => "public", :host => "localhost", :port => 8000}) 

Once connected, you can forward requests or route messages to the server:

# 向消息服务器转发用户上线消息,同时发送用户的好友id列表、群组id列表
client.online(['uid2','uid3', 'uid4'], ['g1', 'g2', 'g3'])

# 向消息服务器转发聊天消息
client.message("uid2", "hahaha")

# 向消息服务器转发用户现场变化
client.presence('busy', "Busy")

# 向消息服务器转发用户状态,例如正在输入...
client.status("uid2", "typing", "I am typing")

# 向消息服务器push即时消息
client.push("uid1", "uid2", "hahaha")

# 从消息服务器读取用户现场信息
client.presences(["uid1", "uid2"])

# 从消息服务器读取当前群组在线用户
client.members('g1')

# 向消息服务器转发用户下线消息
client.offline

Gem build and install

gem build webim.gemspec

gem install webim-0.1.0.gem