private void connectToolStripMenuItem_Click(object sender, EventArgs e) { shard = new ClientShard(); shard.LobbiesAdded += new EventHandler(shard_LobbiesAdded); shard.PlayersAddedToCurrentLobby += new EventHandler(shard_PlayersAddedToCurrentLobby); shard.PlayersRemovedFromCurrentLobby += new EventHandler(shard_PlayersRemovedFromCurrentLobby); shard.GamesAddedToCurrentLobby += new EventHandler(shard_GamesAddedToCurrentLobby); shard.GamesRemovedFromCurrentLobby += new EventHandler(shard_GamesRemovedFromCurrentLobby); shard.ReceivedLobbyChatMessage += new LobbyChatEventHandler(shard_ReceivedLobbyChatMessage); Player player = new Player(""); ConnectForm form = new ConnectForm(); form.Player = player; form.Port = 1331; form.Hostname = "deadofnight.org"; form.ParentShard = shard; if (form.ShowDialog() == DialogResult.OK) { shard.Me = player; } else { shard = null; } }
private void disconnectToolStripMenuItem_Click(object sender, EventArgs e) { if (shard != null && shard.Me != null && shard.Me.Connection != null) { shard.Me.Connection.Stop(); shard.LobbiesAdded -= new EventHandler(shard_LobbiesAdded); shard.PlayersAddedToCurrentLobby -= new EventHandler(shard_PlayersAddedToCurrentLobby); shard.PlayersRemovedFromCurrentLobby -= new EventHandler(shard_PlayersRemovedFromCurrentLobby); shard.GamesAddedToCurrentLobby -= new EventHandler(shard_GamesAddedToCurrentLobby); shard.GamesRemovedFromCurrentLobby -= new EventHandler(shard_GamesRemovedFromCurrentLobby); shard.ReceivedLobbyChatMessage -= new LobbyChatEventHandler(shard_ReceivedLobbyChatMessage); shard = null; treeLobbies.Nodes[0].Nodes.Clear(); treeLobbyContents.Nodes[0].Nodes.Clear(); treeLobbyContents.Nodes[1].Nodes.Clear(); textLobbyMessages.Text = string.Empty; } }
public ClientLobby(string name, ClientShard parentShard) : base(name, parentShard) { }