ChargeTimeEU / Java-OCA-OCPP

Open source client and server library of Open Charge-Point Protocol (OCPP) defined by openchargealliance.org (OCA)
MIT License
274 stars 176 forks source link

Build this on top of javax.websocket-api #60

Open alexm77 opened 6 years ago

alexm77 commented 6 years ago

Building on top of the standard API for WebSockets in java would be safer and more flexible. It complicates the deployment a bit, because of the need to supply the implementation classes, but overall it should be a better solution.

TVolden commented 6 years ago

Hi @alexm77

Thanks for your request. I'll look into it. I'm thinking about exporting soe of the 3rd party dependencies into their own modules, so it's easier to mix and match.

I have allot to see to these next days but hopefully I have something to report by the end of the week.

Thomas

alexm77 commented 6 years ago

All that's needed is https://mvnrepository.com/artifact/javax.websocket/javax.websocket-api/1.1 And then we can add tyrus and whatnot at runtime. I will look into it, but I can't promise I can scrape the time to put a pull request together.

TVolden commented 6 years ago

Hi again,

I'm sorry to say, I haven't had much of a chance to play around with it. I found some examples I would like to go with, but it would require changes to the exposed API. I'd like to have a 0.5 release with the current websocket lib, before I change too much. I'm considering making a 0.5 release branch.

Examples for later: https://stackoverflow.com/questions/26452903/javax-websocket-client-simple-example

alexm77 commented 6 years ago

Yes, I've spent some time on it and I have seen there's a lot to change. It's pretty easy to work with javax-websocket, but it's a bit different from what the current library does.

On Sun, May 13, 2018 at 11:33 PM, Thomas Volden notifications@github.com wrote:

Hi again,

I'm sorry to say, I haven't had much of a chance to play around with it. I found some examples I would like to go with, but it would require changes to the exposed API. I'd like to have a 0.5 release with the current websocket lib, before I change too much. I'm considering making a 0.5 release branch.

Examples for later: https://stackoverflow.com/questions/26452903/javax- websocket-client-simple-example

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ChargeTimeEU/Java-OCA-OCPP/issues/60#issuecomment-388654040, or mute the thread https://github.com/notifications/unsubscribe-auth/AAj9sE22oiwBk3KtxrRpqtXPIhLjyFu-ks5tyJiKgaJpZM4T0jC1 .

dersteve commented 6 years ago

@alexm77 Are you still interested in doing some work on this issue? I would like to use this library together with Spring and Tomcat (as a Server application where chargepoints connect to) and it seems with some modularisation and swapping out the underlying web-socket implementation with javax.websocket we could reach this step together.

alexm77 commented 6 years ago

I've looked into this and it's just too much work. You need to almost rewrite the entire thing for it to work like the JSR does. That said, it's not a herculean task or anything, it can probably be done in a couple of weeks. It's just that I'm not sure I have that much time to spare.

On Tue, Jun 26, 2018 at 12:33 PM, Steve Behrendt notifications@github.com wrote:

@alexm77 https://github.com/alexm77 Are you still interested in doing some work on this issue? I would like to use this library together with Spring and Tomcat (as a Server application where chargepoints connect to) and it seems with some modularisation and swapping out the underlying web-socket implementation with javax.websocket we could reach this step together.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ChargeTimeEU/Java-OCA-OCPP/issues/60#issuecomment-400244812, or mute the thread https://github.com/notifications/unsubscribe-auth/AAj9sG7pts17-Hj2V4k5FVsTHZDzzEROks5uAf_4gaJpZM4T0jC1 .

marcinar commented 4 years ago

You can work around this without changes in the library. I managed to integrate it with Spring WebSocket and Tomcat's implementation of JSR-356.

I can't share the code, but the basic idea is that you make a dummy implementation of eu.chargetime.ocpp.Listener that saves and exposes the ListenerEvents parameter of the open method. You can then pass it to eu.chargetime.ocpp.Server, and call the open method of the server (with some dummy hostname and port), which allows you to retrieve ListenerEvents from your listener.

You can use this object to signal new sessions and messages just like WebSocketListener does. Note that you will need to extend WebSocketReceiver and intercept the RadioEvents parameter of the accept method since the relay method is package-private.

It's not exactly simple, but at least you don't need to use reflection.

frgo commented 3 years ago

Hi @marcinar , I'm also trying to use the lib on a Spring project, the lib works fine when using a different ports for WebSocket and Tomcat. However this is bringing some headaches to deploy the project as an Azure AppService, it seems Azure AppService doesn't allow to expose an aditional port.

I tryied to follow your sugestions to extend the lib, but wasn't able to make it work. Would be possible for you to share just some reference code?

Thanks in advance

kalosha commented 3 years ago

Hi @frgo Could you share with us same example project using Spring? Thanks in advance