コード例 #1
0
        public void ReadXml(XmlReader reader)
        {
            int od = reader.Depth;

            reader.Read();
            while (reader.Depth != od)
            {
                switch (reader.Name)
                {
                case "Protocol":
                    protocol = ProtocolRegistry.GetProtocol(reader.ReadInnerXml());
                    break;

                case "Address":
                    address = reader.ReadInnerXml();
                    break;

                case "Name":
                    name = reader.ReadInnerXml();
                    break;

                case "Port":
                    port = Int32.Parse(reader.ReadInnerXml());
                    break;

                default:
                    reader.ReadInnerXml();
                    break;
                }
            }
            reader.Read();
        }
コード例 #2
0
ファイル: Client.cs プロジェクト: Zacke10/WPFChat
        public void Send()
        {
            try
            {
                NetworkStream n = client.GetStream();
                BinaryWriter  w = new BinaryWriter(n);

                while (true)
                {
                    IChatProtocol temp = messageCollection.Take();
                    n = client.GetStream();
                    w = new BinaryWriter(n);
                    w.Write(temp.ToJSON());
                    w.Flush();
                }
            }

            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                client.Close();
            }
        }
コード例 #3
0
 public NetworkInformation(IChatProtocol protocol, int id, string address, int port, string name, bool useEncryption = false)
     : this()
 {
     Protocol      = protocol;
     Address       = address;
     Port          = port;
     Name          = name;
     Identifier    = id;
     UseEncryption = useEncryption;
 }
コード例 #4
0
 public static void RegisterProtocol(IChatProtocol proto)
 {
     birchProtocols.Add(proto);
 }
コード例 #5
0
 public static void RegisterProtocol (IChatProtocol proto) {
     birchProtocols.Add (proto);
 }
コード例 #6
0
ファイル: Client.cs プロジェクト: Zacke10/WPFChat
 public void AddToSendQueue(IChatProtocol data)
 {
     messageCollection.Add(data);
 }
コード例 #7
0
 public void ReadXml (XmlReader reader) {
     int od = reader.Depth;
     reader.Read ();
     while (reader.Depth != od) {
         switch (reader.Name) {
             case "Protocol":
                 protocol = ProtocolRegistry.GetProtocol (reader.ReadInnerXml ());
                 break;
             case "Address":
                 address = reader.ReadInnerXml ();
                 break;
             case "Name":
                 name = reader.ReadInnerXml ();
                 break;
             case "Port":
                 port = Int32.Parse (reader.ReadInnerXml ());
                 break;
             default:
                 reader.ReadInnerXml ();
                 break;
         }
     }
     reader.Read ();
 }
コード例 #8
0
 public NetworkInformation (IChatProtocol protocol, int id, string address, int port, string name, bool useEncryption = false)
     : this () {
     Protocol = protocol;
     Address = address;
     Port = port;
     Name = name;
     Identifier = id;
     UseEncryption = useEncryption;
 }
コード例 #9
0
 public void ReadXml (XmlReader reader) {
     int od = reader.Depth;
     reader.Read ();
     while (reader.Depth != od) {
         switch (reader.Name) {
             case "Protocol":
                 protocol = ProtocolRegistry.GetProtocol (reader.ReadInnerXml ());
                 break;
             case "Address":
                 address = reader.ReadInnerXml ();
                 break;
             case "Name":
                 name = reader.ReadInnerXml ();
                 break;
             case "Port":
                 port = Int32.Parse (reader.ReadInnerXml ());
                 break;
             case "UseEncryption":
                 useEncryption = reader.ReadInnerXml ().ToLower () == "true";
                 break;
             case "UseGlobalInformation":
                 useGlobalInformation = reader.ReadInnerXml ().ToLower () == "true";
                 break;
             default:
                 reader.ReadInnerXml ();
                 break;
         }
     }
     reader.Read ();
 }