Giter Club home page Giter Club logo

railschat's Introduction

RailsChat

RailsChat是一款由Rails开发的实时Web聊天室,在Render_sync的基础上完成,有需要即时通讯的应用可以考虑这个Example

Online Demo

demo

请点击这里访问Demo,测试用户登陆账号格式为:

username: user<number>@test.com
password: password
  • 其中number为1到20,代表20个用户,例如使用[email protected]password能登陆用户1,以此类推

Note:请用两个浏览器分别登陆不同的用户来测试消息的即使推送,注意这两个用户需要互为好友

目前功能

  • 聊天室消息即时推送
  • 支持查找,添加,删除好友
  • 创建私人聊天,也支持多人聊天
  • 房主可以拉人,踢人
  • 房主能转移房屋权限

Todo

  1. 现在的即时推送只限于聊天的消息,其他的推送比如未读信息提醒(包括声音)等还未涉及
  2. 添加好友需要对方同意,现在是单方面添加
  3. 用户个人简介还未开发
  4. UI界面修改(类似WeChat)
  5. 管理后台开发

Usage

RailsChat详细教程-传送门

  1. Fork项目
git clone https://github.com/your_user_name/RailsChat
cd RailsChat
bundle install
rails server
  1. 然后再打开另外一个终端,运行以下命令启动另外一个server来监听聊天室的用户并实时推送最新的消息:
rackup sync.ru -E production

Note:如果要部署到云上或者本地局域网内,需要修改config/sync.yml文件

以本地局域网为例:

  1. 若本机的ip地址为192.168.0.14(使用ifconfig查看),那么需要将config/sync.yml中的localhost全改为此ip地址,例如
 development:
   server: "http://192.168.0.14:9292/faye"
   adapter_javascript_url: "http://192.168.0.14:9292/faye/faye.js"
   auth_token:  "97c42058e1466902d5adfac0f83e84c1794b9c3390e3b0824be9db8344eae82b"
   adapter: "Faye"
   async: true
   
 test:
   ...
 production:
   ...
  1. 然后运行rake tmp:clear来清除缓存,不然修改不会生效(运行前先将所有相关的运行停止:如rails s,rackup sync.ru等)

  2. 再次运行rails服务器和监听程序,并指定监听程序运行的ip地址

rails s
bundle exec rackup sync.ru -E production --host 192.168.0.14 

Tips:

  1. 在服务器中可以后台运行rack:bundle exec rackup sync.ru -E production --host 192.168.0.14 -D
  2. 若要关闭在后台运行的rackup,请使用ps ax | grep ruby查找相关ruby端口,然后用kill -9 <pid>结束正在运行的rackup,如:
21099 ?        Sl     0:00 /var/www/railschat/RailsChat/vendor/bundle/ruby/2.3.0/bin/rackup                                    
21105 pts/4    S+     0:00 grep --color=auto ruby

Debug

  1. 当遇到消息并没有实时推送的情况时,先F12查看浏览器的Js文件加载情况,若faye.js加载成功则一般不会出现问题

  2. 以上加载完成但是仍然没有推送的时候,请查看Rails服务器的log文件

  3. 需要在两个浏览器中登录不同的账号来检验聊天室功能

截图

如果觉得好,请给项目点颗星来支持吧~~

有什么好的建议,请在issue中提出,欢迎contributors!

railschat's People

Contributors

pengzhaoqing avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.