-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding ping message and pong event to RTM client #459
Adding ping message and pong event to RTM client #459
Conversation
Signed-off-by: Gaspard Petit <[email protected]>
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 <[email protected]>
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
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 [email protected]
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
sendMessage
aPingMessage
and subscribe toPongEvent
In theory, the
PingMessage
could contain any field desired - I am not sure how that can easily be handled especially when reading back thePongEvent
without special handling, but most people should be happy with just atime
field 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
x
in each[ ]
)