/// <summary> /// Constructor for irc connector /// </summary> /// <param name="config"></param> public IrcNetConnector(IrcConfiguration config) { _config = config; _user = new User(config.NickName); _userList = new List<User>(); _userList.Add(_user); _availableChannels = new List<string>(); _connectedChannels = new List<Channel>(); // System messages goes to server tab _connectedChannels.Add(new Channel("server")); _connector = new AsyncConnector(_config.Server, _config.Port); _connector.lineReceive += new onLineReceived(this.onLineRecived); _connector.onConnect += new onConnect(this.onConnect); _connector.onError += new onError(this.onError); _timer = new Timer(); _timer.Interval = 120000; _timer.Elapsed += new ElapsedEventHandler(onWhoTimer); _timer.Enabled = true; }
public IrcTask(IrcConnectorHub client, string connectionId, string uuid, IrcConfiguration config) : base(config) { _hub = client; _connection_id = connectionId; _user_uuid = uuid; _messageQueue = new Queue<IrcMessage>(2000); // Start connection to server connect(); }
public void startIrc(LoginModel model) { _loginData = model; _connectionId = Context.ConnectionId; foreach (IrcTask t in Connections.Values) { if (t.User_uuid.Equals(model.Uuid)) { // Resume old connection Connections.Remove(t.Connection_id); Connections.Add(_connectionId, t); t.Connection_id = _connectionId; t.sendCommand("motd"); t.onConnectionResume(); // Manually trigger user list update function t.onUserListUpdate(); return; } } IrcConfiguration conf = new IrcConfiguration(); conf.Server = _loginData.Server; conf.NickName = _loginData.Name; conf.Channel = _loginData.Channel; if (null != _loginData.Port) { conf.Port = (int)_loginData.Port; } conf.ChannelPassword = _loginData.ChannelPassword; conf.ServerPassword = _loginData.ServerPassword; _stayLogged = _loginData.StayLogged; IrcTask ircTask = new IrcTask(this, _connectionId, _loginData.Uuid, conf); Connections.Add(_connectionId, ircTask); }
static void Main(string[] args) { // Only for testing purposes IrcConfiguration config = new IrcConfiguration(); config.Server = "irc.kzfv.eu"; config.Port = 6668; config.Channel = "testChannel"; config.NickName = "keegiMuu"; IrcNetConnector irc = new IrcNetConnector(config); irc.connect(); // Prevent application from closing*/ bool i = true; while (i == true) { string line = Console.ReadLine(); if (line.Equals("closeme")) { i = false; } else { if (line.StartsWith("/")) irc.sendCommand(line.Substring(1)); else { IrcMessage m = new IrcMessage(); m.Channel = config.Channel; m.Message = line; m.UserName = config.NickName; irc.sendPrivMessage(m); } } } }