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 "JackSocketNotifyChannel.h"
00022 #include "JackError.h"
00023 #include "JackConstants.h"
00024
00025 namespace Jack
00026 {
00027
00028
00029 int JackSocketNotifyChannel::Open(const char* name)
00030 {
00031 jack_log("JackSocketNotifyChannel::Open name = %s", name);
00032
00033
00034 if (fNotifySocket.Connect(jack_client_dir, name, 0) < 0) {
00035 jack_error("Cannot connect client socket");
00036 return -1;
00037 }
00038
00039
00040 fNotifySocket.SetReadTimeOut(SOCKET_TIME_OUT);
00041 return 0;
00042 }
00043
00044 void JackSocketNotifyChannel::Close()
00045 {
00046 jack_log("JackSocketNotifyChannel::Close");
00047 fNotifySocket.Close();
00048 }
00049
00050 void JackSocketNotifyChannel::ClientNotify(int refnum, const char* name, int notify, int sync, const char* message, int value1, int value2, int* result)
00051 {
00052 JackClientNotification event(name, refnum, notify, sync, message, value1, value2);
00053 JackResult res;
00054
00055
00056 if (event.Write(&fNotifySocket) < 0) {
00057 jack_error("Could not write notification");
00058 fNotifySocket.Close();
00059 *result = -1;
00060 return;
00061 }
00062
00063
00064 if (sync) {
00065
00066 if (res.Read(&fNotifySocket) < 0) {
00067 jack_error("Could not read result");
00068 fNotifySocket.Close();
00069 *result = -1;
00070 } else {
00071 *result = res.fResult;
00072 }
00073 } else {
00074 *result = 0;
00075 }
00076 }
00077
00078 }
00079
00080