public bool Call(AbstractService s) { if (s.MessageType != this.typeId) { throw new Exception(String.Format("Wrong Service Type in Send: {0}",s.MessageType)); } return n.CallService(p,s); }
public bool CallService(IntPtr srvPub, AbstractService srv) { int len = srv.GetSize(); IntPtr p = Marshal.AllocHGlobal(len); IntPtr response = Marshal.AllocHGlobal(IntPtr.Size); try { srv.GetData(p); bool test = CallServiceCpp(srvPub, srv.MessageType, p , response); if( test ) { srv.GetResponse(response); //free // double free coruption?? //Free(response); unsafe { char* tmp = *((char**)(response.ToPointer())); Free(tmp); } return true; } return false; } catch(Exception e) { Console.Error.WriteLine("Error while sending: "+e); return false; } finally { Marshal.FreeHGlobal(p); Marshal.FreeHGlobal(response); //Console.WriteLine("freee"); } }