00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "JackRequest.h"
00021 #include "JackWinNamedPipeNotifyChannel.h"
00022 #include "JackError.h"
00023 #include "JackConstants.h"
00024
00025 namespace Jack
00026 {
00027
00028
00029 int JackWinNamedPipeNotifyChannel::Open(const char* name)
00030 {
00031 jack_log("JackWinNamedPipeNotifyChannel::Open name = %s", name);
00032
00033
00034 if (fNotifyPipe.Connect(jack_client_dir, name, 0) < 0) {
00035 jack_error("Cannot connect client pipe");
00036 return -1;
00037 }
00038
00039 fNotifyPipe.SetReadTimeOut(SOCKET_TIME_OUT);
00040 return 0;
00041 }
00042
00043 void JackWinNamedPipeNotifyChannel::Close()
00044 {
00045 jack_log("JackWinNamedPipeNotifyChannel::Close");
00046 fNotifyPipe.Close();
00047 }
00048
00049 void JackWinNamedPipeNotifyChannel::ClientNotify(int refnum, const char* name, int notify, int sync, const char* message, int value1, int value2, int* result)
00050 {
00051 JackClientNotification event(name, refnum, notify, sync, message, value1, value2);
00052 JackResult res;
00053
00054
00055 if (event.Write(&fNotifyPipe) < 0) {
00056 jack_error("Could not write notification");
00057 fNotifyPipe.Close();
00058 *result = -1;
00059 return;
00060 }
00061
00062
00063 if (sync) {
00064
00065 if (res.Read(&fNotifyPipe) < 0) {
00066 jack_error("Could not read result");
00067 fNotifyPipe.Close();
00068 *result = -1;
00069 } else {
00070 *result = res.fResult;
00071 }
00072 } else {
00073 *result = 0;
00074 }
00075 }
00076
00077 }
00078
00079