Giter VIP home page Giter VIP logo

Comments (9)

rohiievych avatar rohiievych commented on September 26, 2024

How this approach differs from the regular RPC call from client to server?
If you subscribe on client events, this will have the same effect as RPC because we have connection.on('message', () => {}) in WsChannel, which is actually low level implementation of api.interfaceName.processEvent(({ message }) => {}).

from metacom.

georgolden avatar georgolden commented on September 26, 2024

This is different from low-level implementation, because there will be metadata in a packet as well. So packet will be recognized by metadata. In some cases, we need async messaging, e.g. some user activity tracking. So basically RPC - remote procedure call. We run procedure in server and expecting response/error within the call directly. Async messaging - we don't care about immediate response. Notifications, user's actions tracking, any similar functionality

from metacom.

georgolden avatar georgolden commented on September 26, 2024

connection.on('message', () => is far not the same as api.interfaceName.processEvent(({ message }) => {}). There is an interfaceName metadata provided withing the packet. So this is an alternative solution, and it looks worse than proposed.

from metacom.

rohiievych avatar rohiievych commented on September 26, 2024

Let me clarify - by saying low level implementation I mean connection.on('message', (msg) => {}), which is placed in WsChannel class and works as a subscription to client messages including protocol metadata like interface name.
It means that api.interfaceName.processEvent(({ message }) => {}) will need additional message subscription.
But do we really need it, while it can be implemented as a simple interface call, where user's metadata is defined by the user and the result of that call is ignored and not awaited?

from metacom.

georgolden avatar georgolden commented on September 26, 2024

The alternative solution just brought confusion to the topic. I removed it. So speaking about proposed solution. It is just mirroring existing functionality, and of course I see this useful to have in metacom. So developer don't need to go to a low level at all and stay within the metacom only, cause metacom is a high-level network library compare to raw WS

from metacom.

georgolden avatar georgolden commented on September 26, 2024

Server-side, we have no direct link to a WS connection available. This would break our abstraction layers. So we need to have such functionality implemented. For client, I am sure it is the same. By design, we don't need to go directly to a WS connection, just to not break abstraction layers/

from metacom.

rohiievych avatar rohiievych commented on September 26, 2024

@tshemsedinov
Need your thoughts on this issue

from metacom.

tshemsedinov avatar tshemsedinov commented on September 26, 2024

Client code is ok for me, but server-side event handler I'd like to have, for example, file onEventName.js with the following code:

({ message }) => {
  if (message === 'hello') {
    context.client.emit('interfaceName/event', 'hi');
  }
};

from metacom.

zaitsev-oleksii avatar zaitsev-oleksii commented on September 26, 2024

Can we implement server-side event handlers as it is?
We have application.getMethod(iname, ver, methodName) in impress for rpc calls, but don't have analogue for events
(sth like application.getEvent(iname, eventName))
We can do client-side event emitting though.

from metacom.

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.