コード例 #1
0
ファイル: CServerBrowser.cpp プロジェクト: DarkKlo/maf2mp
void CServerBrowser::OnClick( CGUIElement_Impl * pElement )
{
	// Get the current serverbrowser type
	ServerBrowserType type = GetCurrentServerBrowserType();

	// Clear the current playerlist
	m_pPlayersGridList->Clear();

	// Have we selected any server?
	if( m_pServerGridList[ type ]->GetSelectedCount() > 0 )
	{
		// Enable the connection button in the main menu
		pCore->GetGUI()->GetMainMenu()->SetConnectButtonVisible( true );

		// Get the selected row index
		int iSelectedIndex = m_pServerGridList[ type ]->GetSelectedItemRow();

		// Find this server from the serverlist
		CServerList * pServerList = GetServerList( type );
		CServerListIterator iter, begin = pServerList->IteratorBegin(), end = pServerList->IteratorEnd();

		// Loop over all servers in the list
		for( iter = begin; iter != end; iter++ )
		{
			// Get the current server
			CServerListItem * pCurrentServer = *iter;

			// Is the current server valid and the one we're looking for?
			if( pCurrentServer && pCurrentServer->iRow == iSelectedIndex )
			{
				// Loop over the players
				for( std::map< std::string, unsigned short >::iterator iter2 = pCurrentServer->m_players.begin(); iter2 != pCurrentServer->m_players.end(); iter2++ )
				{
					// Add a new row in the players grid
					int iRow =  m_pPlayersGridList->AddRow();
					iRow = m_pPlayersGridList->SetItemText ( iRow, 1, (*iter2).first.c_str () );
					iRow = m_pPlayersGridList->SetItemText ( iRow, 2, String ( "%u", (*iter2).second ), true );
				}
			}
		}

		// Store the current selected server
		m_iSelectedServer[ type ] = iSelectedIndex;
	}
	else
	{
		// Disable the connection button
		pCore->GetGUI()->GetMainMenu()->SetConnectButtonVisible( false );
	}
}
コード例 #2
0
ファイル: Login.cpp プロジェクト: XeanoRRR/mmo-resourse
//--------------------------------------------------------------------------
//	功能:全程自动连接
//--------------------------------------------------------------------------
void KLogin::AutoLogin()
{
	ReturnToIdle();
	if (IsAutoLoginEnable())
	{
		m_bInAutoProgress = true;
		if (m_Choices.AccountServer.Address[0] == 0 &&
			m_Choices.AccountServer.Address[1] == 0 &&
			m_Choices.AccountServer.Address[2] == 0 &&
			m_Choices.AccountServer.Address[3] == 0)
		{
			int nCount, nSel;
			KLoginServer* pList = GetServerList(-1, nCount, nSel);
			if (pList)
			{
				free(pList);
				pList = NULL;
			}
		}
		CreateConnection(m_Choices.AccountServer.Address);
	}
}
コード例 #3
0
ファイル: SerManager.cpp プロジェクト: killbug2004/ghost2013
BOOL CSerManager::OnInitDialog() 
{
	CDialog::OnInitDialog();
	

	// TODO: Add extra initialization here
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon


	CString str;
	sockaddr_in  sockAddr;
	memset(&sockAddr, 0, sizeof(sockAddr));
	int nSockAddrLen = sizeof(sockAddr);
	BOOL bResult = getpeername(m_pContext->m_Socket, (SOCKADDR*)&sockAddr, &nSockAddrLen);
	str.Format("\\\\%s - 服务管理", bResult != INVALID_SOCKET ? inet_ntoa(sockAddr.sin_addr) : "");
	SetWindowText(str);

	m_list_server.SetExtendedStyle(/*LVS_EX_FLATSB |*/ LVS_EX_FULLROWSELECT);
	m_list_server.InsertColumn(0, "真实名称", LVCFMT_LEFT, 130);
	m_list_server.InsertColumn(1, "显示名称", LVCFMT_LEFT, 260);
	m_list_server.InsertColumn(2, "启动类型", LVCFMT_LEFT, 60);
	m_list_server.InsertColumn(3, "运行状态", LVCFMT_LEFT, 60);
	m_list_server.InsertColumn(4, "可执行文件路径", LVCFMT_LEFT, 260);

	m_ImgList.Create(16, 16,ILC_COLOR8|ILC_MASK,15,1);
	m_ImgList.Add(AfxGetApp()->LoadIcon(IDI_SYSTEM));
	m_list_server.SetImageList(&m_ImgList,LVSIL_SMALL);

	AdjustList();
	m_list_server.ShowWindow(SW_SHOW);
	if (m_list_server.GetItemCount() == 0)
		GetServerList();
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
コード例 #4
0
ファイル: client.c プロジェクト: skony/sopy
int main(){
  
  int i,j=0;
  ownMSG = OwnMSGInit();
  printf("%d \n", ownMSG);
  SERVER_LIST_RESPONSE res = GetServerList();
  
  server_id = res.servers[0];
  printf("%d\n", server_id);
  sem_login_id = SemLoginInit();
  
  int login_res, change_res;
  while((login_res = Login()) != 201)
    if(login_res == 503){
      printf("server is too busy now...\n");
      sleep(5);
    }
    else if(login_res == 400)
	printf("your name is uncorrect\n");
      else if(login_res == 409)
	  printf("this name already exists\n");
  printf("Login successful! Hello %s\n", name);
  printf("If you first time use this program it's reccomended to try /help\n");
  int pid[2];/*
  if(fork() == 0){
    pid[0] = getpid();
    while(1)
      Heartbeat();
  }
  if(fork() == 0){
    pid[1] = getpid;
    while(1)
      ReceiveText();
  }*/
  char line[MAX_MSG_SIZE];
  while(1){
    printf(">>");
    fgets(line,MAX_MSG_SIZE, stdin);
    j = 0;
    while(line[j] != '\n') j++; 
    line[j] = '\0'; 
    if(strcmp(line, "/help") == 0)
      printf("/users../gusers../priv../logout../rooms../change..\n");
    else if(strcmp(line, "/users") == 0){ 
	CLIENT_LIST_RESPONSE* res = GetClientList();
	for(i=0; i<res->active_clients; i++)
	  printf("%s\n", res->names[i]);
      }
      else if(strcmp(line, "/gusers") == 0){ 
	  CLIENT_LIST_RESPONSE* res = GetGlobalClientList();
	  for(i=0; i<res->active_clients; i++)
	    printf("%s\n", res->names[i]);
	}
	else if(strcmp(line, "/priv") == 0)
	    PrivateText();
	  else if(strcmp(line, "/logout") == 0){
	      Logout();
	      kill(pid[0], 9); kill(pid[1], 9);
	    }
	    else if(strcmp(line, "/rooms") == 0){
		ROOM_LIST_RESPONSE* res = GetRoomList();
		for(i=0; i<res->active_rooms; i++)
		  printf("%s\n", res->rooms[i].name);
	      }
	      else if( (strcmp(line, "/change") == 0) ){
		  while(ChangeRoom() != 202)
		    printf("invalid room name\n");
		  printf("room change successful\n");
		}
		else
		  PublicText(line);
  }
  
  return 0;
}
コード例 #5
0
ファイル: SerManager.cpp プロジェクト: killbug2004/ghost2013
void CSerManager::OnMenuRef() 
{
	GetServerList();	
}