Comments (2)
To create completely different sessions for each locale you can set a
locale specific client.identifier
. You must set this option before the
client connects to the server.
Ex:
var client = new APS(...);
client.identifier = 'site_en';
client.join(...);
...
Let me know if this will work for what you are trying to accomplish.
On Nov 9, 2014 10:16 AM, "moldcraft" [email protected] wrote:
I am building a multi-language site and use ApePubSub to send events from
php via inlinepush command to the users browsers (to update a block on
the homepage, to check if has new messages in chat).I connect the user to 3 channels:
- "main" - events for all users (for e.g. to update the Recent Site
Activity block on the frontpage)- "main:{locale}" ("main:en", "main:fr", ...) - events for users
browsing a concrete locale (for e.g. a chat is accessible only in a
single locale site.com/en/chat/123 http://site.com/en/chat/123, it does
not exist in other locales site.com/fr/chat/123
http://site.com/fr/chat/123 is 404 page)- "user:{username}" - a separate channel for each logged in user, to
send events only to him (for e.g. when he receives a private message, or a
notification that he was banned)The problem was with session and the "main:{locale}" channel:
I open a tab site.com/en and I am subscribed to the main:en channel
2.I open another tab in another locale site.com/fr
- The session is recovered (I am subscribed to the main:en channel)
- I am subscribed to the main:fr channel
No in both tabs I am subscribed to both main:en and main:fr. So in fr
locale I receive events which was meant for en locale, which is not what
I wanted to achieve.
I could leave the user connected to both locale channels, and just write
my code to ignore events that comes from the locales that he is not
currently on. But if the user is currently in the fr locale, where there
is no activity, he may receive a bunch of events from the en locale which
has a lot of activity, this traffic waste and APE server load.I disabled the session {session: false}. Now the problem with locale
channels is resolved (on every refresh the browser creates a new connection
and subscribes to correct channels), but this creates another problem:
Every refresh creates a new user in the channels, and I am afraid that this
will cause overhead for the APE server (it will store 10000 connections
which only 1000 are real/active). I know that the connection is closed
after some seconds of inactivity, but anyway this is may not help when the
site will be frequently accessed and the APE server will be flooded with
connections.Can you recommend something to solve this problem?
Now I am thinking, if I will be able to manually create/recover sessions,
I would create a separate session for each locale: If the session
{some_id}:{locale} exists, restore it, else create it.—
Reply to this email directly or view it on GitHub
#27.
from apepubsub.
Awesome! This is exactly what I was looking for. It works.
Thank you very much
from apepubsub.
Related Issues (20)
- Array.prototype.contains causes error HOT 1
- Accentuated characters cause BAD_JSON error HOT 3
- Sync not working intermittently HOT 13
- IE 10 Websocket connection HOT 1
- 1.3 breaks my App HOT 7
- client.session.destroy() : method doesn't exist unless client has join channel, weird? HOT 2
- ApePubSub Broken with latest Ape. HOT 1
- InlinePush Equivalent HOT 11
- Channel property update HOT 2
- Sync sendEvent with subusers HOT 4
- Channel object not ready on joined event HOT 1
- 'restored' event is not firing HOT 15
- hardcoded http protocol HOT 1
- The "dead" event is triggered twice HOT 1
- var client = new APS('aps.HostName.com'); fails when transport LP HOT 1
- unSub from a channel thows an error if channel is not defined HOT 1
- User can only be in one client instance at a time HOT 1
- Users are NOT sent if you create a non-interactive channel like => *listen HOT 8
- Firefox throws a websocket close error right before loading a page HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apepubsub.