Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a start guide? #1

Closed
FlowerWrong opened this issue Aug 27, 2015 · 18 comments
Closed

Is there a start guide? #1

FlowerWrong opened this issue Aug 27, 2015 · 18 comments

Comments

@FlowerWrong
Copy link

I am new to erlang. And I want to study it.

@wudixiaotie
Copy link
Owner

Sorry, I thougth no one will notice this project. First I just wanted someplace to write my thought. If you want I will write a guide for this.

@FlowerWrong
Copy link
Author

恩,谢谢,我正在研究im,顺便问一下, 你熟悉ejabberd吗?我有两个问题

ejabberd如何实现群聊?

xep-0045中的实现是用户下线会自动退出群聊,上线后需要重新加入该群,但下线期间收不到任何离线消息.如何实现类似微信群聊,whatsapp-like的group chat?

ejabberd如何实现只有朋友关系才能私聊?

xmpp中只要知道对方的jid,且对方没有屏蔽你,那么就可以给对方发送消息.如何实现只有朋友关系才能聊天呢?难道要屏蔽所有人,我觉得这不是一种好的方式.

不宁赐教.
🎱

@wudixiaotie
Copy link
Owner

Group chat : like chat message, but you need to push it to everybody in the group.
About offline group message, just like the way you do with chat message, store it in your server db.

Only friend can talk:
The plan of our company is to limited it at the mobile side, server has no restrictions.

Have fun, :)

@FlowerWrong
Copy link
Author

Thanks a lot. In this way, I need to hack core for

Group chat : like chat message, but you need to push it to everybody in the group.
About offline group message, just like the way you do with chat message, store it in your server db.

But The plan of our company is to limited it at the mobile side, server has no restrictions., I think it is dangerous.

@FlowerWrong
Copy link
Author

@wudixiaotie I use a pubsub + muc_room for implement a whatsapp-like group chat. Use the room only for store room information and pubsub to handle the message both online and offline(May there is no difference in online and offline). In this way, I need to store group users in another db, because I can not get the members of pubsub. I need not hack core.
Right?

@wudixiaotie
Copy link
Owner

Yes, you are right. I told my boss of this about how dangers it is, he seems not quiet agree with me. So what ever. I did my best.

@wudixiaotie
Copy link
Owner

I don't think pubsub is a good idea. I think it is too complex. Group chat message or chat message, they are all messages, so all you need to do is to push the message to the client, if the client is offline, store the message to what ever you want. That is the server's logic.

@FlowerWrong
Copy link
Author

In this way, there is an answer in stackoverflow, ejabberd manual XMPP rules for leaving rooms. It implemented with shared roster.

Possible approach involving a modified mod_muc_room:

  1. On room creation create a Shared Roster group () named {room name}_Participants
  2. Whenever someone joins the room add them to the roster
  3. Whenever someone sends /me leaves then remove them from the roster
  4. Whenever a message is received for the room, send it wrapped in a 'While you were out...' style message to any user in shared roster who is not online
  5. When room is killed remove shared roster

@wudixiaotie
Copy link
Owner

Why need a shared roster? Just a Group Member List store in db, and a cache when im running. When you have group message, find this group member by searching cache,and send them message. That's all you need.

@FlowerWrong
Copy link
Author

So, I need to write a module which is a customed mod_muc_room for this solution.
Also, I need to hack core of single chat for implement single chat must be friends.
Thanks a lot.

@FlowerWrong
Copy link
Author

Hello. I am writting a chat server.
I have a question on supervisor:start_child, the code is here

Error log:

=SUPERVISOR REPORT==== 7-Sep-2015::16:41:03 ===
     Supervisor: {local,erlim_sup}
     Context:    start_error
     Reason:     {noproc,{gen_server,call,
                                     [erlim_session,
                                      {start_child,[#Port<0.3940>]},
                                      infinity]}}
     Offender:   [{pid,undefined},
                  {name,erlim_server},
                  {mfargs,{erlim_server,start_link,[3000]}},
                  {restart_type,permanent},
                  {shutdown,5000},
                  {child_type,worker}]

{error,{{shutdown,{failed_to_start_child,erlim_server,
                                         {noproc,{gen_server,call,
                                                             [erlim_session,{start_child,[#Port<0.3940>]},infinity]}}}},
        {erlim_app,start,[normal,[]]}}}

Can you help me?

@wudixiaotie
Copy link
Owner

You don't need to work? Why you always update your code on working hours?

@FlowerWrong
Copy link
Author

My job now is writting an im server.

@wudixiaotie
Copy link
Owner

cy & ck is your client? Why you always start a tcp connection when you sending message? One client only need one tcp conn for message sending. I think you would better read some book about network. :)

@FlowerWrong
Copy link
Author

Ok, thanks. I have fixed it.

@wudixiaotie
Copy link
Owner

If you want to spawn lots of worker process of a gen_server module. You must not named it.
Your Code Here need to change like this

gen_server:start_link(?MODULE, [Socket], []).

That is why you use supervisor:start_child alway failed at the second time, beause the first time one child process already registered as name "erlim_session".

@FlowerWrong
Copy link
Author

@wudixiaotie How can I receive split data block of big data more then 4k when I set the server buffer to 2k? Also, I can set the buffer size to 8k. But if the data is 64M or more, client must split it into block, then send to server.
My server is here.
Also like this.
🎱

@wudixiaotie
Copy link
Owner

First you need a http server to do upload & download thing. Put everything in a im server is not a good idea.
Second, this issues is closed. You can start a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants