summaryrefslogblamecommitdiffstats
path: root/src/core/pvsChatClient.h
blob: 2cb5d9f89ae1d1a07374cf83ed5acfa6779e5084 (plain) (tree)






































































                                                                              
/*
# Copyright (c) 2009 - OpenSLX Project, Computer Center University of Freiburg
#
# This program is free software distributed under the GPL version 2.
# See http://openslx.org/COPYING
#
# If you have any feedback please consult http://openslx.org/feedback and
# send your suggestions, praise, or complaints to feedback@openslx.org
#
# General information about OpenSLX can be found at http://openslx.org/
*/

// pvsChatClient.h

#ifndef PVSCHATCLIENT_H_
#define PVSCHATCLIENT_H_

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <fstream>
#include <QStringList>
#include <QHash>
#include "src/net/pvsMsg.h"
#include "src/core/pvsChatMsg.h"
#include "src/net/pvsServerConnection.h"
#include "src/util/consoleLogger.h"
#include "src/util/util.h"

class PVS; // forward declaration.

class PVSChatClient
{

public:

    PVSChatClient();
    ~PVSChatClient();
    void setServerConnection(PVSServerConnection* sc);
    void setSource(QString name);
    QString getSource();
    QStringList getClients();
    QString getIPFromUsername(QString username);
    void addClient(QString name, QString ip);
    void removeClient(QString name);
    void clearClients();
    void send(QString tar, QString msg);
    void receive(PVSMsg recv);
    bool isRegistered();
    EventDispatcher<PVSChatMsg>& getChatMsgHandler()
    {
        return _chatMessageDispatcher;
    };
    EventDispatcher<PVSChatMsg>& getChatCommandHandler()
    {
        return _chatCommandDispatcher;
    };

private:

    QString _source;
    bool _registered;
    QStringList _clients;
    QHash<QString, QString> _clientsData;
    PVSServerConnection *_chatServerConnection;
    EventDispatcher<PVSChatMsg> _chatMessageDispatcher;
    EventDispatcher<PVSChatMsg> _chatCommandDispatcher;
};
#endif