Example #1
0
void CGameServSendHandler::SendTo(const void *pData, unsigned long len, const char *sAddr, unsigned long port)
{
	ServerInterface *pMgr;

	if(m_pDlg && (pMgr = m_pDlg->GetServerMgr()))
	{
		pMgr->SendTo(pData, len, sAddr, port);
	}
}
void GuessSpellItem::sendGift()
{
    ServerInterface *server = ServerInterface::getInstance();
    std::string uid = server->getLoginAccountInfo()->m_id;
    std::vector<UiMsgEv::PropDef> props;
    props.push_back(UiMsgEv::PropDef(m_giftType,m_giftCount));
    // 3: social guess.
    server->gainPropAction(uid,3,props);
    showGift();
}
    virtual void plan(ServerInterface &srvInterface,
            NodeSpecifyingPlanContext &planCtxt) {

        /* Check parameters */
        std::vector<ArgEntry> argSpec;
        argSpec.push_back((ArgEntry){"cmd", true, VerticaType(VarcharOID, -1)});
        argSpec.push_back((ArgEntry){"nodes", false, VerticaType(VarcharOID, -1)});
        validateArgs("FileSource", argSpec, srvInterface.getParamReader());

        /* Populate planData */
        // Nothing to do here
        
        /* Munge nodes list */
        findExecutionNodes(srvInterface.getParamReader(), planCtxt, "ANY NODE");
    }
    virtual std::vector<UDSource*> prepareUDSources(ServerInterface &srvInterface,
            NodeSpecifyingPlanContext &planCtxt) {
        std::vector<UDSource*> retVal;
	retVal.push_back(vt_createFuncObj(srvInterface.allocator, ExternalSource,
					  srvInterface.getParamReader().getStringRef("cmd").str()));
        return retVal;
    }
 void Dispatch()
 {
     LDEBUG_CLOCK_TRACE("start event dispatch loop...");
     while(!m_Quit)
     {
         ServerInterface<void>* pInterface = NULL;
         uint32_t events;
         int ready = m_Poll.WaitEvent(&pInterface, &events, m_IdleTimeout);
         try
         {
             if(ready > 0)
             {
                 if((events & PollT::ERR) == PollT::ERR)
                     pInterface->OnError();
                 else if((events & PollT::IN) == PollT::IN)
                     pInterface->OnReadable();
                 else if((events & PollT::OUT) == PollT::OUT)
                     pInterface->OnWriteable();
             }
             else if(ready == 0)
             {
                 for(std::list<boost::function<void(void)> >::iterator iter = m_IdleCallbackList.begin();
                         iter != m_IdleCallbackList.end();
                         ++iter)
                 {
                     (*iter)();
                 }
             }
             for(std::list<boost::function<void(void)> >::iterator iter = m_LoopCallbackList.begin();
                     iter != m_LoopCallbackList.end();
                     ++iter)
             {
                 (*iter)();
             }
         }
         catch(std::exception& error)
         {
             // ignore error
             LOG("unknown error: %s", error.what());
         }
     }
 }
    /*
     * For each partition, executes each string input by forking an invocation
     * of bash.  The resulting output is broken up by newlines and becomes the
     * output rows.
     */
    virtual void processPartition(ServerInterface &srvInterface,
                                  PartitionReader &input_reader,
                                  PartitionWriter &output_writer)
    {
      printf("test\n");
      fflush(stdout);
      // Emulate an ExternalFilter
      DataBuffer input;
      input.buf = (char*)&input_buf[0];
      input.size = sizeof(input_buf);
      input.offset = 0;
      // Fetch data for the initial input buffer
      fillInput(input, sizeof(input_buf), input_reader, 0, false /* keepExistingData */);

      DataBuffer output;
      output.buf = (char*)&output_buf[0];
      output.size = sizeof(output_buf);
      output.offset = 0;
      // Initial output buffer should be empty; no data to fetch

      StreamState state;
      InputState input_state = OK;

      ProcessLaunchingPlugin p(srvInterface.getParamReader().getStringRef("cmd").str(),
			       std::vector<std::string>());

      p.setupProcess();
      
      do {
	state = p.pump(input, input_state, output);

	switch (state) {
	case INPUT_NEEDED: 
	  if (input_state != END_OF_FILE && input_reader.getNumRows() > 0) {
	    input_state = (fillInput(input, sizeof(input_buf), input_reader, 0)
			   ? OK : END_OF_FILE);
	  }
	  break;	  
	case OUTPUT_NEEDED:
	  emitOutput(output, output_writer);
	  break;
	case DONE:
	  break;
	case KEEP_GOING:
	  continue;
	default:
	  vt_report_error(0, "Unsupported StreamState: %d", (int)state);
	}
      } while (state != DONE);

      emitOutput(output, output_writer, true /* flush_output */);

      p.destroyProcess();
    }
Example #7
0
void printBinaryHll(ServerInterface& srvInterface, const char* prefix, const VString& hll) {
  return;
  unsigned int i;
  char buf_str[10000];
  char* buf_ptr = buf_str;

  if (!hll.isNull()) {
      for (i = 0; i < hll.length(); i++)
      {
          buf_ptr += sprintf(buf_ptr, "%02X ", hll.data()[i]);
      }
  }

  *(buf_ptr + 1) = '\0';
  srvInterface.log("%s: %d %s", prefix, hll.length(), buf_str);
}
Example #8
0
BOOL CCoolServApp::AddResources(CStringList& collRezFiles)
{
	// Specify the main resources...

	ServerInterface* pServerMgr = GetServerInterface();
	if (!pServerMgr) return(FALSE);

	char  sTemps[128][128];
	char* sGame[128];
	int   i = 0;

	char* sGameRez  = GetGameRezFile();
	char* sSoundRez = GetSoundRezFile();

	sGame[i++] = sGameRez;
	if (sSoundRez && sSoundRez[0] != '\0') sGame[i++] = sSoundRez;

	sGame[i++] = "custom";


	// Specify the patch, test, and language resources...

	char sGameRezBase[64] = { "" };
	LoadString(g_hInst, IDS_REZBASE, sGameRezBase, 60);

	ADDREZ(sGameRezBase, "P");
	ADDREZ(sGameRezBase, "P2");
	ADDREZ(sGameRezBase, "P3");
	ADDREZ(sGameRezBase, "P4");
	ADDREZ(sGameRezBase, "P5");
	ADDREZ(sGameRezBase, "P6");
	ADDREZ(sGameRezBase, "P7");
	ADDREZ(sGameRezBase, "P8");
	ADDREZ(sGameRezBase, "P9");
	ADDREZ(sGameRezBase, "T");
	ADDREZ(sGameRezBase, "L");


	// Specify the custom resources...

	POSITION pos = collRezFiles.GetHeadPosition();

	while (pos)
	{
		CString sRezFile = collRezFiles.GetNext(pos);

		strcpy(sTemps[i], sRezFile);
		sGame[i] = sTemps[i];
		i++;
	}


	// Add the resources...

	char** sResources = sGame;
	DBOOL  db;

	{
		CWaitCursor wc;

		db = pServerMgr->AddResources(sResources, i);
	}

	if (db != DTRUE)
	{
		AfxMessageBox(IDS_ERROR_LOADREZ);
		return(FALSE);
	}


	// All done...

	return(TRUE);
}