WM_COPYDATA, PostThreadMessage, and Error 1159 - winapi

I am trying to send data from one app to another using WM_COPYDATA. Both apps are console and have no window. I can send user messages just fine. When I try to send WM_COPYDATA, and setup the data structure or not, I get error 1159, which basically says I have to send using a synchronous message call... yet there is no SendThreadMessage.
It seems this is a oversight in the api or docs? There seems to be no way to use WM_COPYDATA using only threads without windows?

WM_COPYDATA can only be sent and cannot be posted. Because the payload is marshaled between processes, temporary data structures are created to support that marshaling. They need to be destroyed when the message processing is complete. That implies that the message must be delivered synchronously.
All of this means that you cannot use PostThreadMessage. Instead you will need to create a window to act as the recipient of such messages. Note that this window can be a message-only window and does not need to be visible.

Related

WM_PAINT while waiting for server response

It seems to me, WM_PAINT messages are send to a window while a thread with this window is waiting for a synchronous response of the COM server. The message appears after a while, or when other actions of user appear. I would like to change background color of the window in this case, but how can I find out, if WM_PAINT is sent as a result of blocking COM server, and not just send in other cases?
I tried to expect a flag while painting, maybe in PAINTSTRUCT, but there I found anything. I need another API call to check this condition.

Unable to get timestamp of the message posted by Slack App

Whenever my app posts ephemeral message to Slack channel (in response to a query by a user), I am unable to get the timestamp of my Slack app response. As I want to delete it once the user has made a selection using one of the buttons. Although I have subscribed to 'message.channels' event, I don't get a notification to my app whenever my app posts in the channel (in response to the user input), therefore, I am unable to get the timestamp of the message which I'll use to delete it. All I want is the timestamp of the message posted by my app so that I can delete it but I am unable to receive the timestamp. Please help!
For e.g. in Giphy app for Slack. Let's say the user invokes the app by calling '/giphy [dog]' where 'dog' is just an example of a search term. The app responds by sending a gif and user can either send it, shuffle to the next one or cancel it. I want a similar capability of cancelling the app response but I need the timestamp of the message in order to do so therefore I am asking for help.
Thanks.
Your approach can not work, because Slack is handling ephemeral messages differently from "normal" messages. They are only visible by one user and can not be modified by API methods (e.g. deletion).
But of course its possible to replace ephemeral messages. Here is how:
Your app can just reply to the interactive message request from Slack with a new message. That new message will by default override the original message including ephemeral messages.
You can reply in two ways:
Directly reply to the request from Slack with a message within 3 seconds
Send a message to the response_url from the Slack request within 30 minutes.
See here for the official documentation on how to respond to interactive messages.
This approach works both with interactive messages and slash commands.
See also this answer for a similar situation.

Symfony3.4 - Send a Server-Sent Event when something happens

I'm developing a project with Symfony 3.4.
I would like to send a message to all the clients currently viewing a page when something happens. I evaluated both Server-Sent Events and Websockets, and I decided to go with the former, because the communication is unidirectional (only server to client).
For this purpose, I'm using this library: https://packagist.org/packages/tonyhhyip/sse
It seems to work, but I need to specifically send a message when something happens in the whole system. I tried with the Symfony event system (by creating a custom event), but events seem to be dispatched and captured only within the same session (i.e., the same logged user). In other words, if an action performed by a user triggers an event, it is not captured by other users and therefore a message is not sent to the browser via SSE.
Any suggestion?
Thank you

HL7 2.X Standard Ackknowledgement

I am trying to write an HL7 message parser that will send a specified acknowledgment back to a messaging engine so that my applicaiton may receive the next message in line.
The interface engine that is sending the messages is call VISTA (has anyone ever worked with it?) I have been told that it expects to receive an 'Ackknowledgement ACK' if there is a value in MSH field 15. In all of the messages that I am currently receiving, I am getting a value of 'AL'.
I have basically set up my application to send a TCP message to a hostname/ip:portnumber that can be set before the applicaiton is started.
If possible, could someone provide a sample ACK message (without sensitive data of course) AND the non-whitspace characters that wrap the message?
I would like to make sure that I know what I need to send back to the sending application.
After some further research of my own, and the help of responses to this post, I have found that the following items are required to be included for the sending applicaiton to accept my ACK and move onto the next message.
The ACK must contain the following:
MSH|^~\&|Receiving App|Receiving App ID|Sending App|Sending App ID|DateTime of Message||"ACK"|Message Control ID|Processing ID|Version ID
MSA|AE <or> AR <or> AA|Message Control ID (MSH 9 from the sent message)
ERR| This particular segment is not required by the sending application
The problem I was experiencing pertained to my Sending and Receiving App IDs and Names were swapped.
Thanks for the help!
I haven't worked with VISTA, and my only current setup is returning an error ACK due to some application issue that I won't be able to debug right now, but in case it's helpful here's the error ACK:
MSH|^~\&|||||20100630130105.496-0500||ACK|20||2.3
MSA|AE|H20091222063637.9834
ERR|^^^207&Application Internal Error&HL70357
Note that this is HL7 v2.3 - the format may be different for other versions.

How can I determine whether a message type is sent or posted?

I'm aware that some messages types are sent directly to window procedures, while others are posted to a thread's message queue, but I haven't found any way to determine if a message will be sent or posted.
MSDN is half-helpful; it explained what's going on but the examples it gives are presumably not exhaustive.
Is there a definitive list of sent vs. posted messages, or a way to decide which type a message is?
Use InSendMessage or InSendMessageEx to determine if you are processing a message that was sent by a call to the SendMessage function.
And some messages are neither posted nor sent. Such is the case of WM_PAINT, WM_TIMER and a few others. They are simply returned by GetMessage when the queue of posted messages are empty.
I'm not sure what applications you are trying to hook, but if you have to ask such questions, then I/m a bit scared. Nothing is more frustrating for a developer to spend time over user-reported crashes only to find out that the cause is from some other application that is injecting misbehaving code. Tread carefully!
Also, Spy++ (tool that ships with Visual Studio) will show you which messages are posted/sent/recevied for any given live windows app.
The MSDN pages documenting each message should be considered the authoritative source for this:
The WM_LBUTTONDOWN message is posted when ...
The WM_SETFOCUS message is sent to a window after ...
etc.

Resources