Adding ping message and pong event to RTM client#459
Adding ping message and pong event to RTM client#459seratch merged 5 commits intoslackapi:masterfrom
Conversation
Signed-off-by: Gaspard Petit <gaspard.petit@eidosmontreal.com>
Codecov Report
@@ Coverage Diff @@
## master #459 +/- ##
============================================
+ Coverage 83.59% 83.65% +0.06%
- Complexity 2386 2387 +1
============================================
Files 250 250
Lines 6442 6442
Branches 590 590
============================================
+ Hits 5385 5389 +4
+ Misses 694 690 -4
Partials 363 363
Continue to review full report at Codecov.
|
|
👋 Thanks again! I will check this later when I have a chance. Can you add an integration test here to help me verify the behavior more easily (also for future maintenance)? |
|
You don't need to run any other tests under the package (they require some preparations). |
…essage-event Signed-off-by: Gaspard Petit <gaspard.petit@eidosmontreal.com>
|
Thank you for pointing me to the right place to add an integration test. It allowed me to fix the I am not very familiar with lombok (although finding it very convenient!); it generated |
|
Also, as a side note, I am >24h in and so far, pinging every 30 seconds has maintained my websocket connection opened with Slack with no other interaction. Generally, my connection drops after 6-10 hours. Perhaps periodic ping should be provided as a built-in feature of the RTM client? |
| public static final String TYPE_NAME = "pong"; | ||
| private final String type = TYPE_NAME; | ||
|
|
||
| private final Long reply_to; |
There was a problem hiding this comment.
Can you define this field as private Long replyTo (camelCase + no need to have final for this) instead? Lombok generates Long getReplyTo() and void setReplyTo(Long) for you.
Regarding the conversion from snake_cased JSON keys, Gson in this project automatically translates snake_case to camelCase. https://github.com/slackapi/java-slack-sdk/blob/v1.0.7/slack-api-client/src/main/java/com/slack/api/rtm/RTMEventsDispatcherImpl.java#L53
There was a problem hiding this comment.
Thanks - good to know!
That's fair enough. Actually, the Python SDK does. If you have time to work on it, it'd be greatly appreciated. Of course, I can work on it after merging this. |
Signed-off-by: Gaspard Petit <gaspard.petit@eidosmontreal.com>
|
I've applied the code formatter and tweaked the test. ac2a010 Thanks for your contribution again! |
* [slack-api-model] Add missing fields in objects (confirm.style in blocks, user.is_invited_user: boolean, message.hidden, Slack post related fields in file objects) - thanks @seratch * [slack-api-client etc] #466 #462 Calls API support - thanks @seratch * [slack-api-client] #475 #474 Make redirect_uri for oauth.access / oauth.v2.access optional - thanks @natevaughan @seratch * [slack-api-client] #476 Bump dependencies (okhttp, micronaut, tyrus-standalone-client) - thanks @seratch * [slack-api-client] #459 Adding ping message and pong event to RTM client - thanks @gaspardpetit * [slack-api-client] #451 Add support and check for the event subtypes in RTM client - thanks @gaspardpetit * [bolt] #455 Improve OAuth flow module to consider the cases where team is missing in oauth.v2.access responses - thanks @seratch * [bolt] #476 Bump dependencies (aws-java-sdk-s3) - thanks @seratch
* [slack-api-model] Add missing fields in objects (confirm.style in blocks, user.is_invited_user: boolean, message.hidden, Slack post related fields in file objects) - thanks @seratch * [slack-api-client etc] slackapi#466 slackapi#462 Calls API support - thanks @seratch * [slack-api-client] slackapi#475 slackapi#474 Make redirect_uri for oauth.access / oauth.v2.access optional - thanks @natevaughan @seratch * [slack-api-client] slackapi#476 Bump dependencies (okhttp, micronaut, tyrus-standalone-client) - thanks @seratch * [slack-api-client] slackapi#459 Adding ping message and pong event to RTM client - thanks @gaspardpetit * [slack-api-client] slackapi#451 Add support and check for the event subtypes in RTM client - thanks @gaspardpetit * [bolt] slackapi#455 Improve OAuth flow module to consider the cases where team is missing in oauth.v2.access responses - thanks @seratch * [bolt] slackapi#476 Bump dependencies (aws-java-sdk-s3) - thanks @seratch
Signed-off-by: Gaspard Petit gaspard.petit@eidosmontreal.com
Summary
It seems like the ping and pong message and event are currently missing from the RTM java client. This change makes it possible to
sendMessageaPingMessageand subscribe toPongEventIn theory, the
PingMessagecould contain any field desired - I am not sure how that can easily be handled especially when reading back thePongEventwithout special handling, but most people should be happy with just atimefield to check how long it took for Slack to respond.(Background on this change - I am currently investigating with the RTM client gets disconnected after a long period of idle time. I suspect sending periodic ping will either keep the websocket alive or will help the client detect when it was disconnected as it will fail to send the
ping.Requirements (place an
xin each[ ])