-
Notifications
You must be signed in to change notification settings - Fork 3
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
xat-server 0.1.0 candidate #48
Open
huumanoid
wants to merge
50
commits into
iiegor:master
Choose a base branch
from
huumanoid:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ers in same pool
… goes to @chat.onPool as String
Conflicts: src/services/client.coffee src/workers/chat.coffee
houndci-bot
reviewed
Oct 12, 2016
database.exec('INSERT INTO messages (id, uid, message, name, registered, avatar, time, pool) values (?, ?, ?, ?, ?, ?, ?, ?)', [ @user.chat, @user.id, message, @user.nickname, @user.username || 'unregistered', @user.avatar, math.time(), @chat.onPool ]).then((data) -> | ||
packet = messageBuilder.buildNewMain( | ||
message: message | ||
client: @ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ must not be used stand alone.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduction
This pull request introduces a bunch of features which may lead xat-server to becase 0.1.0, according to issue list. Let's discuss all this stuff.
Changes
Thanks
Thanks @iiegor for his feedback, i was glad to see you are interested in my collaboration.
#1. Pools
Behavior
When user joins pool, it appears online only for users with same pool.
When user changes pool from 0 to 1, users in 0 receive
<l>
, users in 1 receive<u>
.User sends messages only for users with same pool.
User receives messages only from users with same pool.
Implementation
new method
changePool
added tochat
. This method emit<l>
, changes client'sonPool
and performsjoinRoom
. Later, while implementing banpool, we should usechangePool
to put user to banpool. While implementing rankpool, we should add checks tochangePool
.Pools tests are into
test/pools.coffee
.Issues
Currently, database scheme for
chats
table doesn't containsonPool
field, but it seems thatonPool
lies intopool
field. As for now, it's ok.TODO
Dynamic pools
Original xat server creates additional pools when amount of online users exceed 50, and connects new users to random additional pools.
#2. Ranks
Ranks handling added:
<j2 r="pass"... />
is handled.Behavior
When moderator changes user's rank:
<c>
, if user is on chat.<m t="/m" p="STR_RANK" .. />
.<i>
and<gp>
, if user is on chat (chat packet builder for<i>
and<gp>
introduced).<u>
with actual user's rank, if user is on chat.Restrictions:
Implementation
Ranks stored in
ranks
table of db, ranks are fetched inchat.joinChat
, making handled bychat.makeUser
method. Current code assume that only rank data stored inranks.f
. It means, if we want to add more significant bits toranks.f
, we should change at least this line.Rank
data structure added tosrc/structures/rank.coffee
. Implements rank conversions from/to string/number, rank comparison.Discuss
ranks.f
right? Some insertions intoranks
in sql script contains strange values off
(eg 5).client.user.f
andclient.chat.rank
are dependent fields, but they are parts of plain objects. Probably, we should implement class that would contain some logic based onf
complex nature.Commander
? Is it a tool for chat administrator or server administrator? In first case, we only need to add rank checking to solve Triage important tasks #7.TODO
Fix messaging between connected users #3. Compilation
Compilation task added to
package.json
.Output folder is
lib
.Binary that runs compiled server:
bin/xat-production
To run compiled server, execute:
Tests uses compiled version of chat. To switch to coffee version instead, change symlink
bin/xat-test
, which points to server's binary used to tests.#4. Packet builders
Most of this section content copied from #45
Also, packet builders for chat added.
I've investigated for packet creation methods, which have duplications. I've found, that creation of 'u' packets and 'm' packets for main chat messages are duplicated.
packet-builders/user
andpacket-builders/message
have been created and hardcoded packet composings have been replaced.I think this stuff will evolve as project grows. Some refactoring needed. For example: may be we should impelement separate method for expanding of 'response-to-locate' packet. May be not.
Discuss
We should implement separate methods for online and offline users.
At first sight, it's convenient to create buildUser method, which can recognize, is user online or not, and make fetch user from db in the second case. However, it requires buildUser to be async. Returning promise from buildUser or even using callback may seems fine, but check out this lines. Here, buildUser should be called in cycle. Making an array of promises and passing them to
Promise.all
or making recursive calls of callbacks is not the case. That's why sync version of buildUser() have been created.I think, we can implement unified buildUser method even if there is C# async/await syntax in coffee-script (see ES7 async/await for coffeescript)
#5. Other
@houndci-bot "@ must not be used stand alone"
I propose to ignore this warn. According to coffee-lint docs and coffee-script discussion about standalone @ and this, it's not recommended to use neither standalone
@
northis
. But we need to.