DoctorMcKay / node-steam-user

Allows interaction with the Steam network via the Steam client protocol
https://dev.doctormckay.com/forum/7-node-steam-user/
MIT License
894 stars 157 forks source link

New SteamChatRoomClient Event for friend message acknowledgement #504

Closed laees closed 1 week ago

laees commented 1 week ago

Problem description

I'm trying to detect when a friend chat message has been acknowledge by the logged in user (not the friend). The message acknowledgement is happening in a different session, meaning that my program should be informed when my desktop client reads a friend message.

Possible solution

An event that is fired when the logged in user has read a message with a callback containing:

Current workaround

I tried polling getActiveFriendMessageSessions or getFriendMessageHistory at a set interval to detect when unread_message_count changes. This however is unnecessarily resource intensive and is limited by the polling rate.

I hope this is technically possible.

laees commented 1 week ago

I have found a way to do this by altering ./components/chatroom.js. All I had to do was to add an Event of type FriendMessagesClient.NotifyAckMessageEcho#1 under the //Handlers section

SteamUserBase.prototype._handlerManager.add('FriendMessagesClient.NotifyAckMessageEcho#1', function (body) {
  body = preProcessObject(body);

  /* 
  console.log("Body:\n" + body);
  */

  this.chat.emit("NotifyAckMessageEcho", body);
});