Git Product home page Git Product logo

Comments (2)

ptejada avatar ptejada commented on June 9, 2024

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:

  1. 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.

 avatar commented on June 9, 2024

Awesome! This is exactly what I was looking for. It works.

Thank you very much

from apepubsub.

Related Issues (20)

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.