示例#1
0
 ConnectMessagingEndPoint::~ConnectMessagingEndPoint(){
   ocfaLog(LOG_DEBUG, "Destructor ConnectMessagingEndPoint called");	    
   Message *msg = new ConcreteMessage(_moduleinstance, _moduleinstance, Message::BROADCAST, Message::mtModuleDisconnect, "", "", 0); //If valgring brought you here, please ignore.
   MessageWrapper *mw = new MessageWrapper(MessageWrapper::mwUser, msg);  
   sndMessage(mw);
   _sock_outstream.close();
   //RJM:CODEREVIEW shouldn't we be deleting the message msg and the message wrapper. If not, the MessageWrapper constructor
   //and sndMessage interfaces are wrong (hould use pointer to pointer)
 }
示例#2
0
    // method intended to be used by Clients of the MessageBox
    void ConnectMessagingEndPoint::messageDone(const Message *msg){
      map<const Message *, MessageWrapper *>::iterator itr = _taskmap.find(msg);
      if (itr != _taskmap.end() ){
	itr->second->setType(MessageWrapper::mwTaskProgress);
	sndMessage(itr->second);
	delete msg;
        delete itr->second;
        _taskmap.erase(itr);
      }
    }
示例#3
0
文件: mmwnd.c 项目: chunhualiu/OpenNT
static LRESULT CALLBACK mmWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch (msg)
    {
        case WM_CREATE:
            hwndNotify = hwnd;
            // sndPlaySound(szStartupSound, SND_ASYNC | SND_NODEFAULT);
            break;

        case WM_TIMER:
            KillTimer(hwnd, (UINT)wParam);
            WaveOutNotify(0,0);
            break;

        case MM_MCINOTIFY:
            MciNotify(wParam, lParam);
            break;

        case MM_WOM_DONE:

            /*
                The sound started with sndPlaySound has completed
                so we should call the cleanup routine. We delay
                this call for several hundred milliseconds because
                some sound drivers have a nasty characteristic - they
                will notify before the final DMA transfer is complete
                because the app. supplied buffer is no longer required.
                This means that they may have to spin inside a close
                request until the dma transfer completes. This hangs
                the system for hundreds of milliseconds.

            */

            SetTimer(hwndNotify, 1, SOUND_DELAY, NULL);
            break;

        case MM_SND_PLAY:
            return (LRESULT)(LONG)sndMessage((LPSTR)lParam, (UINT)wParam);

        case MM_MCISYSTEM_STRING:
            return (LRESULT)mciRelaySystemString ((LPMCI_SYSTEM_MESSAGE)lParam);

        default:
            return DefWindowProc(hwnd, msg, wParam,lParam);
    }

    return (LRESULT)0L;
}
示例#4
0
 void ConnectMessagingEndPoint::sendMessage(Message &inMessage){
   getLogStream(LOG_DEBUG) << "Creating messagewrapper" << endl;
   MessageWrapper *omsg = new MessageWrapper(MessageWrapper::mwUser, &inMessage);
   sndMessage(omsg); 
   delete omsg;
 }
示例#5
0
    // this method should only be called by client-like applications
    bool ConnectMessagingEndPoint::connect(){
      ACE_SOCK_Connector _connector_send, _connector_receive ;

      // try creating a listen in range 23200-30000
      int baseport=23200;
      ReceiveSockHandler *receivesockhandler = 0;

      while (baseport < 30000){
	try {
	  receivesockhandler = new ReceiveSockHandler(baseport);
	  break;
	} catch (std::string &e){
	  getLogStream(LOG_INFO) << "SockHandler construct failed for port " << baseport << endl;
	  baseport++;
	}
      }
      if (receivesockhandler == 0){
	throw OcfaException("Create listen failed");
      } else {
	getLogStream(LOG_DEBUG) << "Listening on " << baseport << endl;
      }

      if (ACE_Reactor::instance()->register_handler(receivesockhandler, ACE_Event_Handler::ACCEPT_MASK) == -1){
	ocfaLog(LOG_ERR,"Register of receivehandler failed");
	return false;
      }
     
      // now start the thread which waits for incoming connections
      activate();

      // connect our outgoing stream
      if (_connector_send.connect(_sock_outstream,_remote_addr_send) == -1){
	ocfaLog(LOG_ERR, "connect failed"); 
	return false;  
      } else {
	ocfaLog(LOG_DEBUG, "Connector open succeeded");	
	// connected ! 
	// create message holding info, serialize and send
	ACE_INET_Addr localendpoint;
	_sock_outstream.get_local_addr(localendpoint);
	ostringstream instname; 
	instname << "Inst" << localendpoint.get_port_number();

	// delete the old modinst and replace with a more accurate one
	string mname = _moduleinstance->getModuleName();
	string mnamespace = _moduleinstance->getNameSpace(); 
	delete(_moduleinstance);
	ocfaLog(LOG_DEBUG,"IP is: " + string(localendpoint.get_host_addr()));
	_moduleinstance = new ModuleInstance(localendpoint.get_host_addr(), mname, mnamespace, instname.str());
	_moduleinstance->setPort(localendpoint.get_port_number());

	ModuleInstance *mcopy = new ModuleInstance(*_moduleinstance); 
	mcopy->setPort(localendpoint.get_port_number());
	ostringstream strbaseport;
	strbaseport << baseport;
	Message *sockinfo = new ConcreteMessage(_moduleinstance, mcopy, Message::BROADCAST, Message::mtModuleInstance, strbaseport.str(), "", 0);
	//RJM:CODEREVIEW shouldn't we be deleting mcopy
	MessageWrapper *msgwrapper = new MessageWrapper(MessageWrapper::mwInternalConnect, sockinfo);  
	getLogStream(LOG_DEBUG) << "MessageType: " <<  static_cast<int>(sockinfo->getType()) 
				<< " moduleinstance: " << sockinfo->getReceiver()->getInstanceURI() << endl;
        sndMessage(msgwrapper);	
	ocfaLog(LOG_DEBUG, "Sent message. Deleting");  
	delete msgwrapper;
	delete sockinfo;
	return true;
      }
    }