void OnError(object sender, ErrorEventArgs e) { // Ignore any errors that happen during disconnect if (connectionStatus != ChatConnectionStatus.Disconnecting) { connectionStatus = ChatConnectionStatus.Error; AddNotification("Error: " + e.ErrorMessage); } }
void OnChannelActiveSynced(object sender, IrcEventArgs e) { channel = client.GetChannel(e.Data.Channel); AddNotification("{0} users online".F(channel.Users.Count)); connectionStatus = ChatConnectionStatus.Joined; foreach (DictionaryEntry user in channel.Users) { var u = (ChannelUser)user.Value; Game.RunAfterTick(() => Users.Add(u.Nick, new ChatUser(u.Nick, u.IsOp, u.IsVoice))); } }
void OnDisconnected(object sender, EventArgs e) { Game.RunAfterTick(Users.Clear); // Keep the chat window open if there is an error // It will be cleared by the Disconnect button if (connectionStatus != ChatConnectionStatus.Error) { Game.RunAfterTick(History.Clear); topic = null; connectionStatus = ChatConnectionStatus.Disconnected; } }
void OnKick(object sender, KickEventArgs e) { if (e.Whom == client.Nickname) { Disconnect(); connectionStatus = ChatConnectionStatus.Error; AddNotification("You were kicked from the chat by {0}. ({1})".F(e.Who, e.KickReason)); } else { Users.Remove(e.Whom); AddNotification("{0} was kicked from the chat by {1}. ({2})".F(e.Whom, e.Who, e.KickReason)); } }
void OnConnected(object sender, EventArgs e) { AddNotification("Connected."); connectionStatus = ChatConnectionStatus.Connected; // Guard against settings.yaml modification var nick = SanitizedName(Game.Settings.Chat.Nickname); if (nick != Game.Settings.Chat.Nickname) { Game.RunAfterTick(() => Game.Settings.Chat.Nickname = nick); } client.Login(nick, "in-game IRC client", 0, "OpenRA"); client.RfcJoin("#" + Game.Settings.Chat.Channel); }
void OnConnecting(object sender, EventArgs e) { AddNotification("Connecting to {0}:{1}...".F(Game.Settings.Chat.Hostname, Game.Settings.Chat.Port)); connectionStatus = ChatConnectionStatus.Connecting; }
void OnDisconnecting(object sender, EventArgs e) { if (connectionStatus != ChatConnectionStatus.Error) connectionStatus = ChatConnectionStatus.Disconnecting; }
void OnConnected(object sender, EventArgs e) { AddNotification("Connected."); connectionStatus = ChatConnectionStatus.Connected; // Guard against settings.yaml modification var nick = SanitizedName(Game.Settings.Chat.Nickname); if (nick != Game.Settings.Chat.Nickname) Game.RunAfterTick(() => Game.Settings.Chat.Nickname = nick); client.Login(nick, "in-game IRC client", 0, "OpenRA"); client.RfcJoin("#" + Game.Settings.Chat.Channel); }
public void Disconnect() { // Error is an alias for disconnect, but keeps the panel open // so that clients can see the error if (connectionStatus == ChatConnectionStatus.Error) { Game.RunAfterTick(History.Clear); topic = null; connectionStatus = ChatConnectionStatus.Disconnected; } else connectionStatus = ChatConnectionStatus.Disconnecting; if (!client.IsConnected) return; client.RfcQuit(Game.Settings.Chat.QuitMessage); AddNotification("Disconnecting from {0}...".F(client.Address)); Game.RunAfterTick(() => Game.Settings.Chat.ConnectAutomatically = false); }
public void Connect() { if (client.IsConnected) return; new Thread(() => { try { client.Connect(Game.Settings.Chat.Hostname, Game.Settings.Chat.Port); } catch (Exception e) { connectionStatus = ChatConnectionStatus.Error; AddNotification(e.Message); Game.RunAfterTick(() => Log.Write("irc", e.ToString())); return; } client.Listen(); }) { Name = "IrcListenThread", IsBackground = true }.Start(); }
void OnKick(object sender, KickEventArgs e) { Disconnect(); connectionStatus = ChatConnectionStatus.Error; AddNotification("Error: You were kicked from the chat by {0}".F(e.Who)); }