Esempio n. 1
0
void Manager::ManageIncMsg() {
  while (!inc_msg_.empty()) {
    network::Message *msg = inc_msg_.front();
    network::Message::MessageType type = msg->GetType();

    std::string name;
    switch (type) {
      case network::Message::kTypeLogin:
        int fd;
        msg->Extract(name);
        msg->Extract(fd);
        LoginClient(fd, name);
        break;
      case network::Message::kTypeLogout:
        boost::uuids::uuid uid;
        msg->Extract(uid);
        LogoutClient(uid);
        break;
      case network::Message::kTypeChat:
        network::Message::ChatMessage chat;
        std::string chat_msg;
        msg->Extract(chat);
        msg->Extract(name);
        msg->Extract(chat_msg);
        ChatMessage(chat, name, chat_msg);
        break;
    }

    inc_msg_.pop();
    delete msg;
  }
}
Esempio n. 2
0
File: server.c Progetto: skony/sopy
int main() {
    int y=0;
    InitMSGs();
    Register();
    if(fork() == 0)
        while(1)
            PublicText();
    if(fork() == 0)
        while(1)
            SendServerList();
    if(fork() == 0)
        while(1)
            LoginClient();
    if(fork() == 0)
        while(1)
            SendUsersList();
    if(fork() == 0)
        while(1)
            SendRoomsList();
    if(fork() == 0)
        while(1)
            SendUsersOnRoomList();
    if(fork() == 0)
        while(1)
            ChangeUserRoom();

    while(y == 0) {

    }
    //Unregister();

    //wait(NULL);

    return 0;

}