Comments (7)
Ah, I see.
The main reason why this library doesn't index the clients for you is because there are so many different ways in which you might want to do it. You could easily find yourself in a situation where you have multiple clients connecting with the same (duplicate) identities, but differing protocols, paths, "virtual" hosts, etc...
Anyway, I'm glad this solution works for your case. Thanks.
from ocpp-rpc.
Hi @ease
Is the express server instance and RPCServer instance part of the same application? Or is the express server running in one application and the RPCServer running in the other?
You can use this module for implementing RPC between different applications, although I suspect this may not be what you need.
from ocpp-rpc.
It's the latter -> express server running on port 3000 and the RPCServer running on 80.
Since client identity and RPCServer instance are important to me and I'd like to comply with the rules you've put in the lib, what would you recommend for express server to RPCServer communication? If it wasn't this library and doing it via WebSockets (e.g. ws
) we'd just emit event from express and listen to it on the WebSocket server. Here I'm trying to do the same in a correct way using your library and hoping to get some guidance on how to do it properly and what could be the right method I should use? How can I access the underlying socket and send events from the backend to RPCServer? I thought it's sendRaw
as mentioned above.
Thanks for the quick response.
from ocpp-rpc.
If you wanted to send messages to an RPCServer, then you'd be best to use an RPCClient. There's no reason to use sendRaw
unless you're doing some low-level debugging of the protocol.
You can create an RPCClient instance alongside your express app and have it connect to your existing RPCServer using a custom protocol. This would allow you to re-use the RPCServer to serve both your OCPP chargepoints and your custom RPC protocol at the same time.
from ocpp-rpc.
Yeah that makes sense and I've managed to pass the data using a custom protocol, but the issue I have with that is that I have a single reference to the client
in
server.on('client', (client) => {
// Here, I'll have a reference to the RPCClient which is my express app, but I'd also like to have
// the ability to talk to charger that'd also be connected to this server
// I'd like to catch the event from the custom protocol (from backend) here and pass it to the
// charger to perform `.call` on the charger, not on the RPCClient which is my express backend.
})
How to achieve getting both express's client reference and real charger's client reference?
Perhaps I'd need to store each of the clients in my own way as soon as I notice a new client? I was wondering if I can do that using your library since you're already filling the array/Set of _.clients
with the each new incoming client, and also have implemented the methods for adding and deleting a client.
from ocpp-rpc.
A common way to reference different clients is by their differing identities - but you'd need to create this index yourself as the library doesn't include this as a feature.
Here's an example of how I've done this before.
You could then reference your different clients like so:
clients.get('ExpressServer').call(/* something */);
clients.get('Charger').call(/* something */);
from ocpp-rpc.
Thanks, I had that in mind and I'm around the same idea of using identities. I've noticed you're storing each new client under the private property (_clients
) so I was thinking that I've missed something in your docs about that Map being exposed somewhere and just wanted to check.
Thanks for the suggestions, I think you can close this now.
from ocpp-rpc.
Related Issues (20)
- Unable to set chargingProfileKind. HOT 6
- Fail to run README samples HOT 4
- Feat: Add option to prevent queueing of calls while in CONNECTING state
- Reserved word "package" is used as a variable name in util.js
- client.call() listens to 'abort' event from passed signal, but does not unregister after call complete
- Feat: RPCClient should take an AbortSignal as a constructor option to close() on abort
- Wildcard handler HOT 2
- Module Not Found HOT 4
- Handshake with the same Charging point keeps on happening again and again. HOT 14
- How do StartTransactions work HOT 2
- Correct way to send a handshake or connect HOT 3
- Difficulty Setting Charging Profile After Clearing an Existing Profile for Dynamic Load Balancing HOT 2
- Issues with events HOT 3
- RPCServer 'upgradeAborted' event can fire after websocket upgrade is successful HOT 1
- Central system microservice HOT 7
- Example for using this package in a project that uses ESM module HOT 4
- Correct way to set the maximum watt a charger can charge in a RemoteStartTransaction. HOT 28
- Disconnects after 30 sec HOT 3
- Error While Disconnecting from Webscoket Client 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 ocpp-rpc.