static void Main(string[] args) { Text avt; avt = new Text(); avt.messageCode = 5; avt.messageNumber = 1000; avt.text = "kuba"; byte[] b = Util.Wrap(avt); System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); Console.WriteLine(encoding.GetString(b)); Message msg = Util.Unwrap(b); if (msg is Text) { Text at = (Text)msg; Console.WriteLine(at.messageCode); Console.WriteLine(at.messageNumber); Console.WriteLine(at.text); Console.WriteLine(); Console.ReadKey(); } else { Console.WriteLine("Nieudane typowanie obiektu."); } }
private void button1_Click(object sender, EventArgs e) { Text text = new Text(); text.user = "******"; text.channelName = "edf"; text.text = "siema"; handle_Message(text); }
public void handle_Message(Text text) { String channel = text.channelName; Console.WriteLine("to jes ttoo co odbieramy od kuby: " + channel); String user = text.user; String message_text = text.text; chat temp_chat = null; foreach (chat c in channels) { if (c.channelname == channel) { Console.WriteLine("to jest nasz wybrany czat: " + c.channelname); temp_chat = c; } } if (temp_chat != null) temp_chat.handle_Message(text); }
public void sendMessage(String msg, String channel) { Text to_send = new Text(); to_send.user = nick; to_send.text = msg; to_send.channelName = channel; byte[] wrappedMessage = Util.Wrap(to_send); System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); Console.WriteLine(encoding.GetString(wrappedMessage)); //connect(); udp_client.Send(wrappedMessage, wrappedMessage.Length); }
public void handle_Message(Text text) { String user = text.user; String message_text = text.text; this.chatBox.AppendText(user + ": " + message_text + '\n'); }