From e41e68fdd576bc77580be8b30bd83359a7abb358 Mon Sep 17 00:00:00 2001 From: pyrinoff Date: Thu, 21 Apr 2022 17:12:40 +0300 Subject: [PATCH] fix for Longpool Message > MessageObject. Not tested properly! --- README.md | 14 +++++--------- .../main/java/com/vk/api/sdk/events/Events.java | 2 +- .../java/com/vk/api/sdk/events/EventsHandler.java | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 6718c04b..8981efda 100644 --- a/README.md +++ b/README.md @@ -363,17 +363,13 @@ vk.groups().setLongPollSettings(groupActor).enabled(true) Override methods from CallbackApiLongPoll class for handling events and create needed constructors ```java -public class CallbackApiLongPollHandler extends CallbackApiLongPoll { - public CallbackApiLongPollHandler(VkApiClient client, UserActor actor, Integer groupId) { - super(client, actor, groupId); - } - - public CallbackApiLongPollHandler(VkApiClient client, GroupActor actor) { - super(client, actor); +public class CallbackApiLongPollHandler extends GroupLongPollApi { + public CallbackApiLongPollHandler(VkApiClient client, GroupActor actor, int waitTime) { + super(client, actor, waitTime); } @Override - public void messageNew(Integer groupId, Message message) { + public void messageNew(Integer groupId, MessageObject message) { System.out.println("messageNew: " + message.toString()); } @@ -384,7 +380,7 @@ public class CallbackApiLongPollHandler extends CallbackApiLongPoll { } ``` -In order to use the created ```CallbackApiLongPollHandler``` which overrides methods from CallBackApiLongPoll, +In order to use the created ```CallbackApiLongPollHandler``` which overrides methods from ```GroupLongPollApi```, the instance of it needs to be created and method ```run``` called ```java diff --git a/sdk/src/main/java/com/vk/api/sdk/events/Events.java b/sdk/src/main/java/com/vk/api/sdk/events/Events.java index e910f16b..4509a41e 100644 --- a/sdk/src/main/java/com/vk/api/sdk/events/Events.java +++ b/sdk/src/main/java/com/vk/api/sdk/events/Events.java @@ -15,7 +15,7 @@ public enum Events { @SerializedName("message_new") - MESSAGE_NEW(Message.class), + MESSAGE_NEW(MessageObject.class), @SerializedName("message_reply") MESSAGE_REPLY(Message.class), diff --git a/sdk/src/main/java/com/vk/api/sdk/events/EventsHandler.java b/sdk/src/main/java/com/vk/api/sdk/events/EventsHandler.java index 70d20a94..fad9ce04 100644 --- a/sdk/src/main/java/com/vk/api/sdk/events/EventsHandler.java +++ b/sdk/src/main/java/com/vk/api/sdk/events/EventsHandler.java @@ -31,7 +31,7 @@ protected String confirmation() { return null; } - protected void messageNew(Integer groupId, Message message) { + protected void messageNew(Integer groupId, MessageObject message) { LOG.error(OVERRIDING_ERR); }