Ejemplo n.º 1
0
        public void sendToServer(ChatWindow fromChatroom, Packet packet)
        {
            int chatroomIndex;

            if (fromChatroom != null)
            {
                chatroomIndex = chatWindows.IndexOf(fromChatroom);
            }
            else
            {
                chatroomIndex = -1;
            }
            packet.changeChatroomIndex(chatroomIndex);
            byte[] dataSand = packet.getPacket();

            // debug
            //Console.Write("Send command: "); Console.WriteLine(packet.getCommand());
            //Console.Write("Send Chat room num: "); Console.WriteLine(chatroomIndex);

            try
            {
                client.send(dataSand);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }