Пример #1
0
        public MainChat(Login loginWindow)
        {
            InitializeComponent();

            this.WindowParent = loginWindow;
            SelfClient = loginWindow.SelfClient;

            heartPackageData = Encoding.UTF8.GetBytes(
                JsonData.ConvertToText(
                    JsonData.Create(new TransPackage()
                    {
                        Name = WindowParent.NickName,
                        Content = null,
                        ClientGuid = WindowParent.ClientGuid,
                        PackageType = ConstDef.HeartPackage
                    })));

            getOnlineInfoPackageData = Encoding.UTF8.GetBytes(
                JsonData.ConvertToText(
                    JsonData.Create(new TransPackage()
                    {
                        Name = WindowParent.NickName,
                        Content = null,
                        ClientGuid = WindowParent.ClientGuid,
                        PackageType = ConstDef.ReportChannelOnline
                    })));

            DataObject.AddPastingHandler(InputBox, InputBox_OnPaste);
        }
Пример #2
0
 private bool TrySendPackage(TransPackage package)
 {
     JsonData jsonToSend = JsonData.Create(package);
     string textToSend = JsonData.ConvertToText(jsonToSend);
     byte[] bytesToSend = Encoding.UTF8.GetBytes(textToSend);
     return TrySendData(bytesToSend);
 }