コード例 #1
0
ファイル: StateStatus.cs プロジェクト: evelinad/Talk2Me
 public static StateStatus Desserialize(byte[] data)
 {
     StateStatus result = new StateStatus();
     using (MemoryStream m = new MemoryStream(data))
     {
         using (BinaryReader reader = new BinaryReader(m))
         {
             result.Id = reader.ReadInt32();
             result.State = reader.ReadString();
             result.Status = reader.ReadString();
             result.User = reader.ReadString();
         }
     }
     return result;
 }
コード例 #2
0
ファイル: ClientWindow.xaml.cs プロジェクト: evelinad/Talk2Me
        private void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ConnSQL connSQL = new ConnSQL();

            connSQL.update(user.Username, (comboBox1.SelectedItem as ComboBoxItem).Content.ToString());
            if ((comboBox1.SelectedItem as ComboBoxItem).Content.ToString().CompareTo("Offline") == 0)
            {

                StateStatus mess = new StateStatus();
                mess.Id = 1;
                mess.State = "Offline";
                mess.Status = "";
                mess.User = user.Username;
                byte[] buff = mess.Serialize();

                ClientServerCommunicator.SendData(ClientServerCommunicator.server_socket, buff, 5);

                parrentwdw.Show();
                signout = true;
                this.Close();
            }

            if ((comboBox1.SelectedItem as ComboBoxItem).Content.ToString().CompareTo("Available") == 0)
            {
                


                StateStatus mess = new StateStatus() ;
                mess.Id = 1;
                mess.State ="Available";
                mess.Status = "";
                mess.User = user.Username;
                byte[] buff = mess.Serialize();

                ClientServerCommunicator.SendData(ClientServerCommunicator.server_socket, buff, 5);
            }


            if ((comboBox1.SelectedItem as ComboBoxItem).Content.ToString().CompareTo("Invisible") == 0)
            {
                

                StateStatus mess = new StateStatus();
                mess.Id = 1;
                mess.State = "Invisible";
                mess.Status = "";
                mess.User = user.Username;
                byte[] buff = mess.Serialize();

                ClientServerCommunicator.SendData(ClientServerCommunicator.server_socket, buff, 5);
            }
        }