private void SentChannelMessages(Server server, Channel channel, string message) { if (this.InvokeRequired) { setChannelCallback s = new setChannelCallback(SentChannelMessages); this.Invoke(s,new object[] {server,channel,message}); } else { this.PrintToChatWindow(server, message); } }
private void JoinedChannel(Server server,Channel channel) { TreeNode newChannel = new TreeNode(); newChannel.Name = "channelNode_"+ channel.Name; newChannel.Text = channel.Name; TreeNode[] serverNode = this.ChannelList.Nodes.Find("serverNode_" + server.Name, false); serverNode[0].Nodes.Add(newChannel); this.SelectChannelListNode(newChannel); }
private void ReceivedChannelCommands(Server server, Channel channel, string message) { if (this.InvokeRequired) { setChannelCallback s = new setChannelCallback(ReceivedChannelCommands); this.Invoke(s, new object[] { server, channel, message }); } else { switch (message) { case "NAMES": this.UserBox.DataSource = channel.NickNames; break; case "JOIN": this.UserBox.DataSource = channel.NickNames; break; case "TOPIC": this.ChannelTitle.Text = channel.Title; break; } } }
private void SentChannelCommands(Server server, Channel channel, string message) { if (this.InvokeRequired) { setChannelCallback s = new setChannelCallback(SentChannelCommands); this.Invoke(s, new object[] { server, channel, message }); } else { switch (message) { case "JOIN": this.JoinedChannel(server, channel); break; case "PART": this.LeftChannel(server, channel); break; //default: this.ChatWindow.AppendText(message + " \n"); break; } } }
private void LeftChannel(Server server, Channel channel) { TreeNode[] serverNode = this.ChannelList.Nodes.Find("serverNode_" + server.Name, false); TreeNode[] channelNode = serverNode[0].Nodes.Find("channelNode_" + channel.Name, false); serverNode[0].Nodes.Remove(channelNode[0]); }
public void SentChannelMessages(Channel channel,string message) { if (this.selectedChannel == channel.Name) { if (this.ChannelSentMessages != null) { this.ChannelSentMessages(this, channel, message.Trim()); } } }
public void SentChannelCommands(Channel channel, string message) { if (this.selectedChannel == channel.Name) { if (this.ChannelSentCommands != null) { this.ChannelSentCommands(this, channel, message); } } }
/** * for when the client joins a channel */ public void JoinChannel(string channelName) { this.SendCommand("JOIN",channelName); Channel joinedChannel = new Channel(this,channelName); this.connectedChannels.Add(channelName,joinedChannel); //if (this.ChannelEvent != null) { this.ChannelEvent(this, joinedChannel, "JOIN"); } if (this.ChannelSentCommands != null) { this.ChannelSentCommands(this, joinedChannel, "JOIN"); } }
public void Connect(string host, int port, string username, string name, string password, string nickname) { hostNameParts = new string[host.Split('.').Length]; hostNameParts = host.Split('.'); this.serverChannel = new Channel(this, hostNameParts[1]); this.host = host; this.port = port; this.username = username; this.nickname = nickname; if (name == null) { this.name = hostNameParts[1]; } else { this.name = name; } this.password = password; this.connection = new TcpClient(this.host, this.port); if (this.ServerCommandsSent != null) { this.ServerCommandsSent(this, "CONNECT"); } this.reader = new StreamReader(this.connection.GetStream()); this.writer = new StreamWriter(this.connection.GetStream()); this.Authenticate(); this.isConnected = true; this.Listen(); }