IRCServer.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef IRC_SERVER_H_
  17. #define IRC_SERVER_H_
  18. #include "../client.h"
  19. #include "IRCChannel.h"
  20. #include "IRCMessage.h"
  21. //maximum host length for an irc server
  22. #define IRC_HOST_LEN_MAX 256
  23. //maximum nick name on an irc server for the client
  24. #define IRC_NICK_LEN_MAX 32
  25. class IRCServer {
  26. public:
  27. IRCServer();
  28. IRCServer(int32 character_id, const char *host, short port, const char *nick);
  29. IRCServer(const char *host, short port, const char *nick);
  30. virtual ~IRCServer();
  31. const char * GetHost() {return host;}
  32. short GetPort() {return port;}
  33. bool IsConnected() {return connected;}
  34. vector<IRCChannel* > * GetChannels() {return &channels;}
  35. IRCChannel * GetChannel(const char *channel_name);
  36. IRCChannel * GetChannel(int32 channel_index);
  37. int Connect();
  38. void Disconnect();
  39. int JoinChannel(const char *channel_name);
  40. int LeaveChannel(const char *channel_name);
  41. int Say(const char *channel_name, const char *message);
  42. int Say(int32 channel_index, const char *message);
  43. bool Process();
  44. private:
  45. int32 character_id;
  46. char host[IRC_HOST_LEN_MAX + 1]; //host (eg. irc.myircserver.com)
  47. short port; //port (default is typically 6667)
  48. char nick[IRC_NICK_LEN_MAX + 1];
  49. int sockfd; //socket used to connect to the irc server
  50. vector<IRCChannel *> channels;
  51. bool connected;
  52. void ProcessLine(Client *client, const char *line);
  53. void Send(IRCMessage *message);
  54. void HandlePing();
  55. void Say(IRCChannel *channel, const char *message);
  56. bool m_globalServer;
  57. };
  58. #endif