Ejemplo n.º 1
0
void IRCSession::processResponse(shared_ptr<IIRCCommand> command)
{
	OS_ASSERT(command != nullptr);
	
	switch(command->getType())
	{
	case ircCommandTypeMessage:				processCommandMessage(boost::dynamic_pointer_cast<IRCCommandMessage>(command));
											break;

	case ircCommandTypeChannelListStart:	invalidateChannels();
											break;

	case ircCommandTypeChannel:				{
												shared_ptr<IRCCommandChannel> commandChannel = boost::dynamic_pointer_cast<IRCCommandChannel>(command);
												OS_ASSERT(commandChannel != nullptr);
												validateChannel(commandChannel->getChannelName(), commandChannel->getChannelDescription(), commandChannel->getChannelUsers());
											}

											break;

	case ircCommandTypeChannelListEnd:		updateChannels(true);
											break;

	case ircCommandTypeJoin:				processCommandJoin(boost::dynamic_pointer_cast<IRCCommandJoin>(command));
											break;

	case ircCommandTypePart:				processCommandPart(boost::dynamic_pointer_cast<IRCCommandPart>(command));
											break;

	case ircCommandTypeNames:				processCommandNames(boost::dynamic_pointer_cast<IRCCommandNames>(command));
											break;

	case ircCommandTypeEndOfNames:			processCommandEndOfNames(boost::dynamic_pointer_cast<IRCCommandEndOfNames>(command));
											break;

	case ircCommandTypeQuit:				processCommandQuit(boost::dynamic_pointer_cast<IRCCommandQuit>(command));
											break;

	case ircCommandTypeNick:				processCommandNick(boost::dynamic_pointer_cast<IRCCommandNick>(command));
											break;

	case ircCommandTypeMode:				processCommandMode(boost::dynamic_pointer_cast<IRCCommandMode>(command));
											break;

	case ircCommandTypeKick:				processCommandKick(boost::dynamic_pointer_cast<IRCCommandKick>(command));
											break;
	}
}
void Client::start() {
	socket.setUpSocket();
	socket.connectTo("127.0.0.1",31000);
	ClientReceiverThread *receiverThread = new ClientReceiverThread(&socket,user);
        receiverThread->start();
	string command;
	while (true)
        {
            showNotification();
            cout<<"> ";
            cin>>command;
            if (command=="signup"){
                proccessCommandSignup();
            }
            else if (command=="login"){
                proccessCommandLogin();
            }
            else if (command=="message"){
                proccessCommandMessage();
            }
            else if (command=="show")
            {
                proccessCommandShow();
            }
            else if (command=="create")
            {
            	processCommandCreate();
            }
            else if (command=="join")
            {
            	processCommandJoin();
            }
            else if (command=="leave")
            {
            	processCommandLeave();
            }
            else if (command=="logout")
            {
                processCommandLogout();
            }
            else if (command=="sendFile")
            {
                processCommandSendFile();
            }
	}
	socket.closeSocket();
}